* [PATCH][next] soc: fsl: dpio: fix memory leak of a struct qbman on error exit path
@ 2019-02-19 14:05 Colin King
2019-02-19 20:56 ` Leo Li
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-02-19 14:05 UTC (permalink / raw)
To: Roy Pledge, Li Yang, linuxppc-dev, linux-arm-kernel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the error check for a null reg leaks a struct qbman
that was allocated earlier. Fix this by kfree'ing p on the error exit
path.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/soc/fsl/dpio/qbman-portal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c
index 0bddb85c0ae5..5a73397ae79e 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -180,6 +180,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
reg = qbman_read_register(p, QBMAN_CINH_SWP_CFG);
if (!reg) {
pr_err("qbman: the portal is not enabled!\n");
+ kfree(p);
return NULL;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: [PATCH][next] soc: fsl: dpio: fix memory leak of a struct qbman on error exit path
2019-02-19 14:05 [PATCH][next] soc: fsl: dpio: fix memory leak of a struct qbman on error exit path Colin King
@ 2019-02-19 20:56 ` Leo Li
0 siblings, 0 replies; 2+ messages in thread
From: Leo Li @ 2019-02-19 20:56 UTC (permalink / raw)
To: Colin King, Roy Pledge, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Colin King <colin.king@canonical.com>
> Sent: Tuesday, February 19, 2019 8:05 AM
> To: Roy Pledge <roy.pledge@nxp.com>; Leo Li <leoyang.li@nxp.com>;
> linuxppc-dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH][next] soc: fsl: dpio: fix memory leak of a struct qbman on
> error exit path
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the error check for a null reg leaks a struct qbman that was
> allocated earlier. Fix this by kfree'ing p on the error exit path.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied for next. Thanks.
> ---
> drivers/soc/fsl/dpio/qbman-portal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/soc/fsl/dpio/qbman-portal.c
> b/drivers/soc/fsl/dpio/qbman-portal.c
> index 0bddb85c0ae5..5a73397ae79e 100644
> --- a/drivers/soc/fsl/dpio/qbman-portal.c
> +++ b/drivers/soc/fsl/dpio/qbman-portal.c
> @@ -180,6 +180,7 @@ struct qbman_swp *qbman_swp_init(const struct
> qbman_swp_desc *d)
> reg = qbman_read_register(p, QBMAN_CINH_SWP_CFG);
> if (!reg) {
> pr_err("qbman: the portal is not enabled!\n");
> + kfree(p);
> return NULL;
> }
>
> --
> 2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-19 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-19 14:05 [PATCH][next] soc: fsl: dpio: fix memory leak of a struct qbman on error exit path Colin King
2019-02-19 20:56 ` Leo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox