* [PATCH][next] media: cxd2880-spi: fix two memory leaks of dvb_spi
@ 2018-12-22 14:12 Colin King
2019-01-07 2:25 ` Yasunari.Takiguchi
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-12-22 14:12 UTC (permalink / raw)
To: Yasunari Takiguchi, Mauro Carvalho Chehab, linux-media
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/media/spi/cxd2880-spi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
index d5c433e20d4a..3499c90dc695 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)
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;
+ if (ret)
+ goto fail_adapter;
}
dvb_spi->spi = spi;
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH][next] media: cxd2880-spi: fix two memory leaks of dvb_spi
2018-12-22 14:12 [PATCH][next] media: cxd2880-spi: fix two memory leaks of dvb_spi Colin King
@ 2019-01-07 2:25 ` Yasunari.Takiguchi
0 siblings, 0 replies; 2+ messages in thread
From: Yasunari.Takiguchi @ 2019-01-07 2:25 UTC (permalink / raw)
To: colin.king, mchehab, linux-media
Cc: kernel-janitors, linux-kernel, Yasunari.Takiguchi
Hi Colin
Thanks for finding that.
Acked-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>
Takiguchi
> -----Original Message-----
> From: Colin King [mailto:colin.king@canonical.com]
> Sent: Saturday, December 22, 2018 11:12 PM
> To: Takiguchi, Yasunari (SSS); Mauro Carvalho Chehab;
> linux-media@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH][next] media: cxd2880-spi: fix two memory leaks of dvb_spi
>
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
> ---
> drivers/media/spi/cxd2880-spi.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/spi/cxd2880-spi.c
> b/drivers/media/spi/cxd2880-spi.c
> index d5c433e20d4a..3499c90dc695 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)
>
> 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;
> + if (ret)
> + goto fail_adapter;
> }
>
> dvb_spi->spi = spi;
> --
> 2.19.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-07 2:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 14:12 [PATCH][next] media: cxd2880-spi: fix two memory leaks of dvb_spi Colin King
2019-01-07 2:25 ` Yasunari.Takiguchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).