hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/memstick/core/memstick.c
....@@ -1,15 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Sony MemoryStick support
34 *
45 * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com>
56 *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
107 * Special thanks to Carlos Corbacho for providing various MemoryStick cards
118 * that made this driver possible.
12
- *
139 */
1410
1511 #include <linux/memstick.h>
....@@ -416,6 +412,7 @@
416412 return card;
417413 err_out:
418414 host->card = old_card;
415
+ kfree_const(card->dev.kobj.name);
419416 kfree(card);
420417 return NULL;
421418 }
....@@ -445,6 +442,9 @@
445442 } else if (host->card->stop)
446443 host->card->stop(host->card);
447444
445
+ if (host->removing)
446
+ goto out_power_off;
447
+
448448 card = memstick_alloc_card(host);
449449
450450 if (!card) {
....@@ -471,8 +471,10 @@
471471 put_device(&card->dev);
472472 host->card = NULL;
473473 }
474
- } else
474
+ } else {
475
+ kfree_const(card->dev.kobj.name);
475476 kfree(card);
477
+ }
476478 }
477479
478480 out_power_off:
....@@ -548,6 +550,7 @@
548550 */
549551 void memstick_remove_host(struct memstick_host *host)
550552 {
553
+ host->removing = 1;
551554 flush_workqueue(workqueue);
552555 mutex_lock(&host->lock);
553556 if (host->card)