Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubi: Put MTD device after it is not used

The MTD device reference is dropped via put_mtd_device, however its
field ->index is read and passed to ubi_msg. To fix this, the patch
moves the reference dropping after calling ubi_msg.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Pan Bian and committed by
Richard Weinberger
b95f83ab d62e98ed

+1 -1
+1 -1
drivers/mtd/ubi/build.c
··· 1101 1101 ubi_wl_close(ubi); 1102 1102 ubi_free_internal_volumes(ubi); 1103 1103 vfree(ubi->vtbl); 1104 - put_mtd_device(ubi->mtd); 1105 1104 vfree(ubi->peb_buf); 1106 1105 vfree(ubi->fm_buf); 1107 1106 ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index); 1107 + put_mtd_device(ubi->mtd); 1108 1108 put_device(&ubi->dev); 1109 1109 return 0; 1110 1110 }