]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: saa7146: add cleanup in hexium_attach()
authorWenwen Wang <wenwen@cs.uga.edu>
Sun, 18 Aug 2019 05:40:14 +0000 (02:40 -0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 16 Oct 2019 09:55:25 +0000 (11:55 +0200)
BugLink: https://bugs.launchpad.net/bugs/1847155
[ Upstream commit 42e64117d3b4a759013f77bbcf25ab6700e55de7 ]

If saa7146_register_device() fails, no cleanup is executed, leading to
memory/resource leaks. To fix this issue, perform necessary cleanup work
before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/media/pci/saa7146/hexium_gemini.c

index 659c4e88ce0c92e7254c78a44e69e37022c65993..7ec3445aed41a9532f2fcbb50f8e4a03dd1834e8 100644 (file)
@@ -303,6 +303,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
        ret = saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER);
        if (ret < 0) {
                pr_err("cannot register capture v4l2 device. skipping.\n");
+               saa7146_vv_release(dev);
+               i2c_del_adapter(&hexium->i2c_adapter);
+               kfree(hexium);
                return ret;
        }