mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 15:40:03 +02:00
mtd: ubi: Release device reference on busy detach
ubi_detach_mtd_dev() obtains a device reference through ubi_get_device()
before checking whether the UBI device is busy. The busy return path drops
ubi->ref_count but leaves the device reference held, so the device object
cannot be released after a later detach.
Drop the device reference before returning -EBUSY.
Fixes: 7e84c961b2 ("mtd: ubi: introduce pre-removal notification for UBI volumes")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
5b0a6b554e
commit
31dd710cd8
|
|
@ -1105,6 +1105,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
|
|||
ubi->ref_count -= 1;
|
||||
if (ubi->ref_count) {
|
||||
if (!anyway) {
|
||||
put_device(&ubi->dev);
|
||||
spin_unlock(&ubi_devices_lock);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user