]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: cxd2880-spi: fix two memory leaks of dvb_spi
authorColin Ian King <colin.king@canonical.com>
Sat, 22 Dec 2018 14:12:26 +0000 (09:12 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 16 Jan 2019 16:44:29 +0000 (11:44 -0500)
There are two return paths that do not kfree dvb_spi. Fix the memory
leaks by returning via the exit label fail_adapter that will free
dvi_spi.

Detected by CoverityScan, CID#1475991 ("Resource Leak")

Fixes: cb496cd472af ("media: cxd2880-spi: Add optional vcc regulator")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>?
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/spi/cxd2880-spi.c

index d5c433e20d4af30da51f3dff6741c642e4544c47..4077217777f92efdf03115e319bbd95997685264 100644 (file)
@@ -522,13 +522,15 @@ cxd2880_spi_probe(struct spi_device *spi)
 
        dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc");
        if (IS_ERR(dvb_spi->vcc_supply)) {
-               if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER)
-                       return -EPROBE_DEFER;
+               if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) {
+                       ret = -EPROBE_DEFER;
+                       goto fail_adapter;
+               }
                dvb_spi->vcc_supply = NULL;
        } else {
                ret = regulator_enable(dvb_spi->vcc_supply);
                if (ret)
-                       return ret;
+                       goto fail_adapter;
        }
 
        dvb_spi->spi = spi;