]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
media: ttpci: fix two memleaks in budget_av_attach
authorZhipeng Lu <alexious@zju.edu.cn>
Wed, 21 Feb 2024 05:17:04 +0000 (13:17 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 28 Feb 2024 15:00:33 +0000 (16:00 +0100)
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>
drivers/media/pci/ttpci/budget-av.c

index 230b104a7cdf07172e41000cca4fff777a510a96..a47c5850ef87582526b9798d1d2292d8716e05fe 100644 (file)
@@ -1463,7 +1463,8 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
                budget_av->has_saa7113 = 1;
                err = saa7146_vv_init(dev, &vv_data);
                if (err != 0) {
-                       /* fixme: proper cleanup here */
+                       ttpci_budget_deinit(&budget_av->budget);
+                       kfree(budget_av);
                        ERR("cannot init vv subsystem\n");
                        return err;
                }
@@ -1472,9 +1473,10 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
                vv_data.vid_ops.vidioc_s_input = vidioc_s_input;
 
                if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_VIDEO))) {
-                       /* fixme: proper cleanup here */
-                       ERR("cannot register capture v4l2 device\n");
                        saa7146_vv_release(dev);
+                       ttpci_budget_deinit(&budget_av->budget);
+                       kfree(budget_av);
+                       ERR("cannot register capture v4l2 device\n");
                        return err;
                }