Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ab0ed48

Browse files
tititiou36Hans Verkuil
authored andcommitted
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: f50c4ca ("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>
1 parent 266b44e commit ab0ed48

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

drivers/media/pci/intel/ipu6/ipu6-isys.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,20 @@ static const struct dev_pm_ops isys_pm_ops = {
925925
.resume = isys_resume,
926926
};
927927

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+
928942
static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount)
929943
{
930944
struct device *dev = &isys->adev->auxdev.dev;
@@ -1105,12 +1119,14 @@ static int isys_probe(struct auxiliary_device *auxdev,
11051119

11061120
ret = isys_register_devices(isys);
11071121
if (ret)
1108-
goto out_remove_pkg_dir_shared_buffer;
1122+
goto free_fw_msg_bufs;
11091123

11101124
ipu6_mmu_hw_cleanup(adev->mmu);
11111125

11121126
return 0;
11131127

1128+
free_fw_msg_bufs:
1129+
free_fw_msg_bufs(isys);
11141130
out_remove_pkg_dir_shared_buffer:
11151131
if (!isp->secure_mode)
11161132
ipu6_cpd_free_pkg_dir(adev);
@@ -1137,16 +1153,9 @@ static void isys_remove(struct auxiliary_device *auxdev)
11371153
struct ipu6_bus_device *adev = auxdev_to_adev(auxdev);
11381154
struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev);
11391155
struct ipu6_device *isp = adev->isp;
1140-
struct isys_fw_msgs *fwmsg, *safe;
11411156
unsigned int i;
11421157

1143-
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head)
1144-
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
1145-
fwmsg, fwmsg->dma_addr, 0);
1146-
1147-
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head)
1148-
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
1149-
fwmsg, fwmsg->dma_addr, 0);
1158+
free_fw_msg_bufs(isys);
11501159

11511160
isys_unregister_devices(isys);
11521161
isys_notifier_cleanup(isys);

0 commit comments

Comments
 (0)