Skip to content

Commit d0b07f7

Browse files
AlexiousLuHans Verkuil
authored andcommitted
media: ttpci: fix two memleaks in budget_av_attach
When saa7146_register_device and saa7146_vv_init fails, budget_av_attach should free the resources it allocates, like the error-handling of ttpci_budget_init does. Besides, there are two fixme comment refers to such deallocations. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent b9b6838 commit d0b07f7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/media/pci/ttpci/budget-av.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,8 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
14631463
budget_av->has_saa7113 = 1;
14641464
err = saa7146_vv_init(dev, &vv_data);
14651465
if (err != 0) {
1466-
/* fixme: proper cleanup here */
1466+
ttpci_budget_deinit(&budget_av->budget);
1467+
kfree(budget_av);
14671468
ERR("cannot init vv subsystem\n");
14681469
return err;
14691470
}
@@ -1472,9 +1473,10 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
14721473
vv_data.vid_ops.vidioc_s_input = vidioc_s_input;
14731474

14741475
if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_VIDEO))) {
1475-
/* fixme: proper cleanup here */
1476-
ERR("cannot register capture v4l2 device\n");
14771476
saa7146_vv_release(dev);
1477+
ttpci_budget_deinit(&budget_av->budget);
1478+
kfree(budget_av);
1479+
ERR("cannot register capture v4l2 device\n");
14781480
return err;
14791481
}
14801482

0 commit comments

Comments
 (0)