Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: intel/ipu6: Fix an error handling path in isys_probe()

If an error occurs after a successful alloc_fw_msg_bufs() call, some
resources should be released as already done in the remove function.

Add a new free_fw_msg_bufs() function that releases what has been allocated
by alloc_fw_msg_bufs().

Also use this new function in isys_remove() to avoid some code duplication.

Fixes: f50c4ca0a820 ("media: intel/ipu6: add the main input system driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Christophe JAILLET and committed by
Hans Verkuil
ab0ed481 266b44ec

+18 -9
+18 -9
drivers/media/pci/intel/ipu6/ipu6-isys.c
··· 925 925 .resume = isys_resume, 926 926 }; 927 927 928 + static void free_fw_msg_bufs(struct ipu6_isys *isys) 929 + { 930 + struct device *dev = &isys->adev->auxdev.dev; 931 + struct isys_fw_msgs *fwmsg, *safe; 932 + 933 + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) 934 + dma_free_attrs(dev, sizeof(struct isys_fw_msgs), fwmsg, 935 + fwmsg->dma_addr, 0); 936 + 937 + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) 938 + dma_free_attrs(dev, sizeof(struct isys_fw_msgs), fwmsg, 939 + fwmsg->dma_addr, 0); 940 + } 941 + 928 942 static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount) 929 943 { 930 944 struct device *dev = &isys->adev->auxdev.dev; ··· 1119 1105 1120 1106 ret = isys_register_devices(isys); 1121 1107 if (ret) 1122 - goto out_remove_pkg_dir_shared_buffer; 1108 + goto free_fw_msg_bufs; 1123 1109 1124 1110 ipu6_mmu_hw_cleanup(adev->mmu); 1125 1111 1126 1112 return 0; 1127 1113 1114 + free_fw_msg_bufs: 1115 + free_fw_msg_bufs(isys); 1128 1116 out_remove_pkg_dir_shared_buffer: 1129 1117 if (!isp->secure_mode) 1130 1118 ipu6_cpd_free_pkg_dir(adev); ··· 1153 1137 struct ipu6_bus_device *adev = auxdev_to_adev(auxdev); 1154 1138 struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev); 1155 1139 struct ipu6_device *isp = adev->isp; 1156 - struct isys_fw_msgs *fwmsg, *safe; 1157 1140 unsigned int i; 1158 1141 1159 - list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) 1160 - dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), 1161 - fwmsg, fwmsg->dma_addr, 0); 1162 - 1163 - list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) 1164 - dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), 1165 - fwmsg, fwmsg->dma_addr, 0); 1142 + free_fw_msg_bufs(isys); 1166 1143 1167 1144 isys_unregister_devices(isys); 1168 1145 isys_notifier_cleanup(isys);