Skip to content

Commit 4e180af

Browse files
rgenoudgregkh
authored andcommitted
mtd: nandsim: bugfix: fail if overridesize is too big
commit bb0a13a upstream. If override size is too big, the module was actually loaded instead of failing, because retval was not set. This lead to memory corruption with the use of the freed structs nandsim and nand_chip. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d419593 commit 4e180af

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/mtd/nand/nandsim.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,7 @@ static int __init ns_init_module(void)
23332333
uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize;
23342334
if (new_size >> overridesize != nsmtd->erasesize) {
23352335
NS_ERR("overridesize is too big\n");
2336+
retval = -EINVAL;
23362337
goto err_exit;
23372338
}
23382339
/* N.B. This relies on nand_scan not doing anything with the size before we change it */

0 commit comments

Comments
 (0)