LKML Archive on
help / color / mirror / Atom feed
* [PATCH] sdio: Fix a memory leaking bug in wl1271_probe()
@ 2019-05-23 13:53 Gen Zhang
  0 siblings, 0 replies; only message in thread
From: Gen Zhang @ 2019-05-23 13:53 UTC (permalink / raw)
  To: kvalo, eyalreizer; +Cc: netdev, linux-kernel

In wl1271_probe(), 'glue->core' is allocated by platform_device_alloc(),
when this allocation fails, ENOMEM is returned. However, 'pdev_data'
and 'glue' are allocated by devm_kzalloc() before 'glue->core'. When
platform_device_alloc() returns NULL, we should also free 'pdev_data'
and 'glue' before wl1271_probe() ends to prevent leaking memory.

Signed-off-by: Gen Zhang <>
diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
index 4d4b0770..e134f30 100644
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -340,7 +340,7 @@ static int wl1271_probe(struct sdio_func *func,
 	if (!glue->core) {
 		dev_err(glue->dev, "can't allocate platform_device");
 		ret = -ENOMEM;
-		goto out;
+		goto out_free;
 	glue->core->dev.parent = &func->dev;
@@ -385,6 +385,10 @@ static int wl1271_probe(struct sdio_func *func,
+	devm_kfree(&func->dev, pdev_data);
+	devm_kfree(&func->dev, glue);
 	return ret;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-23 13:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 13:53 [PATCH] sdio: Fix a memory leaking bug in wl1271_probe() Gen Zhang

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).