diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-12-22 09:12:26 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-01-16 11:44:29 -0500 |
commit | c54dbfcda3059c255f335e75a27d7f5c64e6549e (patch) | |
tree | 06b7d73aca573cbdb518a492355f845628b8185f | |
parent | 9502cdf0807058a10029488052b064cecceb7fc9 (diff) |
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: 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>
-rw-r--r-- | drivers/media/spi/cxd2880-spi.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c index d5c433e20d4a..4077217777f9 100644 --- a/drivers/media/spi/cxd2880-spi.c +++ b/drivers/media/spi/cxd2880-spi.c | |||
@@ -522,13 +522,15 @@ cxd2880_spi_probe(struct spi_device *spi) | |||
522 | 522 | ||
523 | dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc"); | 523 | dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc"); |
524 | if (IS_ERR(dvb_spi->vcc_supply)) { | 524 | if (IS_ERR(dvb_spi->vcc_supply)) { |
525 | if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) | 525 | if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) { |
526 | return -EPROBE_DEFER; | 526 | ret = -EPROBE_DEFER; |
527 | goto fail_adapter; | ||
528 | } | ||
527 | dvb_spi->vcc_supply = NULL; | 529 | dvb_spi->vcc_supply = NULL; |
528 | } else { | 530 | } else { |
529 | ret = regulator_enable(dvb_spi->vcc_supply); | 531 | ret = regulator_enable(dvb_spi->vcc_supply); |
530 | if (ret) | 532 | if (ret) |
531 | return ret; | 533 | goto fail_adapter; |
532 | } | 534 | } |
533 | 535 | ||
534 | dvb_spi->spi = spi; | 536 | dvb_spi->spi = spi; |