| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Sony MemoryStick support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> |
|---|
| 5 | 6 | * |
|---|
| 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 | | - * |
|---|
| 10 | 7 | * Special thanks to Carlos Corbacho for providing various MemoryStick cards |
|---|
| 11 | 8 | * that made this driver possible. |
|---|
| 12 | | - * |
|---|
| 13 | 9 | */ |
|---|
| 14 | 10 | |
|---|
| 15 | 11 | #include <linux/memstick.h> |
|---|
| .. | .. |
|---|
| 416 | 412 | return card; |
|---|
| 417 | 413 | err_out: |
|---|
| 418 | 414 | host->card = old_card; |
|---|
| 415 | + kfree_const(card->dev.kobj.name); |
|---|
| 419 | 416 | kfree(card); |
|---|
| 420 | 417 | return NULL; |
|---|
| 421 | 418 | } |
|---|
| .. | .. |
|---|
| 445 | 442 | } else if (host->card->stop) |
|---|
| 446 | 443 | host->card->stop(host->card); |
|---|
| 447 | 444 | |
|---|
| 445 | + if (host->removing) |
|---|
| 446 | + goto out_power_off; |
|---|
| 447 | + |
|---|
| 448 | 448 | card = memstick_alloc_card(host); |
|---|
| 449 | 449 | |
|---|
| 450 | 450 | if (!card) { |
|---|
| .. | .. |
|---|
| 471 | 471 | put_device(&card->dev); |
|---|
| 472 | 472 | host->card = NULL; |
|---|
| 473 | 473 | } |
|---|
| 474 | | - } else |
|---|
| 474 | + } else { |
|---|
| 475 | + kfree_const(card->dev.kobj.name); |
|---|
| 475 | 476 | kfree(card); |
|---|
| 477 | + } |
|---|
| 476 | 478 | } |
|---|
| 477 | 479 | |
|---|
| 478 | 480 | out_power_off: |
|---|
| .. | .. |
|---|
| 548 | 550 | */ |
|---|
| 549 | 551 | void memstick_remove_host(struct memstick_host *host) |
|---|
| 550 | 552 | { |
|---|
| 553 | + host->removing = 1; |
|---|
| 551 | 554 | flush_workqueue(workqueue); |
|---|
| 552 | 555 | mutex_lock(&host->lock); |
|---|
| 553 | 556 | if (host->card) |
|---|