Skip to content

Commit bb0a13a

Browse files
rgenoudDavid Woodhouse
authored andcommitted
mtd: nandsim: bugfix: fail if overridesize is too big
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. Cc: stable@vger.kernel.org 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>
1 parent 5bf3d66 commit bb0a13a

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
@@ -2317,6 +2317,7 @@ static int __init ns_init_module(void)
23172317
uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize;
23182318
if (new_size >> overridesize != nsmtd->erasesize) {
23192319
NS_ERR("overridesize is too big\n");
2320+
retval = -EINVAL;
23202321
goto err_exit;
23212322
}
23222323
/* N.B. This relies on nand_scan not doing anything with the size before we change it */

0 commit comments

Comments
 (0)