Skip to content

Commit

Permalink
media: cxd2880-spi: fix two memory leaks of dvb_spi
Browse files Browse the repository at this point in the history
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: cb496cd ("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>
  • Loading branch information
Colin Ian King authored and Mauro Carvalho Chehab committed Jan 16, 2019
1 parent 9502cdf commit c54dbfc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/media/spi/cxd2880-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c54dbfc

Please sign in to comment.