Commit c54dbfcd authored by Colin Ian King's avatar Colin Ian King Committed by Mauro Carvalho Chehab

media: cxd2880-spi: fix two memory leaks of dvb_spi

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: cb496cd4 ("media: cxd2880-spi: Add optional vcc regulator")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>?
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 9502cdf0
...@@ -522,13 +522,15 @@ cxd2880_spi_probe(struct spi_device *spi) ...@@ -522,13 +522,15 @@ cxd2880_spi_probe(struct spi_device *spi)
dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc"); dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc");
if (IS_ERR(dvb_spi->vcc_supply)) { if (IS_ERR(dvb_spi->vcc_supply)) {
if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) {
return -EPROBE_DEFER; ret = -EPROBE_DEFER;
goto fail_adapter;
}
dvb_spi->vcc_supply = NULL; dvb_spi->vcc_supply = NULL;
} else { } else {
ret = regulator_enable(dvb_spi->vcc_supply); ret = regulator_enable(dvb_spi->vcc_supply);
if (ret) if (ret)
return ret; goto fail_adapter;
} }
dvb_spi->spi = spi; dvb_spi->spi = spi;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment