Skip to contentSkip to conversation

memstick: fix a double-free bug in memstick_check

PATCH In review Qinglang Miao 2 participants 2 messages Nov 20, 2020 – Nov 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memstick: fix a double-free bug in memstick_check

kfree(host->card) has been called in put_device so that another kfree would raise cause a double-free bug.

Fixes 0193383a5833 ("memstick: core: fix device_register() error handling")
---
 drivers/memstick/core/memstick.c | 1 -
 1 file changed, 1 deletion(-)
drivers/memstick/core/memstick.c +0 -1
index ef03d6faf..12bc3f5a6 100644
@@ -468,7 +468,6 @@ static void memstick_check(struct work_struct *work)
 			host->card = card;
 			if (device_register(&card->dev)) {
 				put_device(&card->dev);
-				kfree(host->card);
 				host->card = NULL;
 			}
 		} else
Signature · 1 line
2.23.0
#1 lore raw
Quoted 7 lines · Qinglang Miao

kfree(host->card) has been called in put_device so that another kfree would raise cause a double-free bug.

Fixes 0193383a5833 ("memstick: core: fix device_register() error handling")

Applied for next, thanks!

Kind regards
Uffe

Quoted 19 lines
---
 drivers/memstick/core/memstick.c | 1 -
 1 file changed, 1 deletion(-)
drivers/memstick/core/memstick.c +0 -2
index ef03d6faf..12bc3f5a6 100644
@@ -468,7 +468,6 @@ static void memstick_check(struct work_struct *work)
                        host->card = card;
                        if (device_register(&card->dev)) {
                                put_device(&card->dev);
-                               kfree(host->card);
                                host->card = NULL;
                        }
                } else
--

2.23.0