[PATCH v2] usb: host: sl811_cs: fix memory leak on probe failure
From: Zongmin Zhou
Date: Mon Aug 31 2026 - 22:11:15 EST
From: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>
sl811_cs_probe() leaks the local_info_t allocated into link->priv when
sl811_cs_config() fails: the only kfree() lives in the remove callback
sl811_cs_detach(), which the PCMCIA core never calls for a device whose
probe failed.
Free the private data when sl811_cs_config() fails.
Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
Reviewed-by: Nikolay Kulikov <nikolayof23@xxxxxxxxx>
Signed-off-by: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>
---
Changes in v2:
- Fix the Fixes tag to 15b99ac17295, the commit that made
sl811_cs_config() failures observable as probe failures.
- Add Reviewed-by from Nikolay Kulikov.
drivers/usb/host/sl811_cs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index ada91ca33f65..fd0cd541bf53 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -177,6 +177,7 @@ failed:
static int sl811_cs_probe(struct pcmcia_device *link)
{
local_info_t *local;
+ int ret;
local = kzalloc_obj(local_info_t);
if (!local)
@@ -184,7 +185,11 @@ static int sl811_cs_probe(struct pcmcia_device *link)
local->p_dev = link;
link->priv = local;
- return sl811_cs_config(link);
+ ret = sl811_cs_config(link);
+ if (ret)
+ kfree(local);
+
+ return ret;
}
static const struct pcmcia_device_id sl811_ids[] = {
--
2.34.1
No virus found
Checked by Hillstone Network AntiVirus