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

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>

authored by

Zhipeng Lu and committed by
Hans Verkuil
d0b07f71 b9b68384

+5 -3
+5 -3
drivers/media/pci/ttpci/budget-av.c
··· 1463 1463 budget_av->has_saa7113 = 1; 1464 1464 err = saa7146_vv_init(dev, &vv_data); 1465 1465 if (err != 0) { 1466 - /* fixme: proper cleanup here */ 1466 + ttpci_budget_deinit(&budget_av->budget); 1467 + kfree(budget_av); 1467 1468 ERR("cannot init vv subsystem\n"); 1468 1469 return err; 1469 1470 } ··· 1473 1472 vv_data.vid_ops.vidioc_s_input = vidioc_s_input; 1474 1473 1475 1474 if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_VIDEO))) { 1476 - /* fixme: proper cleanup here */ 1477 - ERR("cannot register capture v4l2 device\n"); 1478 1475 saa7146_vv_release(dev); 1476 + ttpci_budget_deinit(&budget_av->budget); 1477 + kfree(budget_av); 1478 + ERR("cannot register capture v4l2 device\n"); 1479 1479 return err; 1480 1480 } 1481 1481