Commit 3afd522d authored by Roel Kluin's avatar Roel Kluin Committed by David Woodhouse

[MTD] slram: Handle negative devlength correctly

A negative devlength won't get noticed and clean up:
Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 5f877607
...@@ -267,22 +267,28 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength) ...@@ -267,22 +267,28 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
if (*(szlength) != '+') { if (*(szlength) != '+') {
devlength = simple_strtoul(szlength, &buffer, 0); devlength = simple_strtoul(szlength, &buffer, 0);
devlength = handle_unit(devlength, buffer) - devstart; devlength = handle_unit(devlength, buffer) - devstart;
if (devlength < devstart)
goto err_out;
devlength -= devstart;
} else { } else {
devlength = simple_strtoul(szlength + 1, &buffer, 0); devlength = simple_strtoul(szlength + 1, &buffer, 0);
devlength = handle_unit(devlength, buffer); devlength = handle_unit(devlength, buffer);
} }
T("slram: devname=%s, devstart=0x%lx, devlength=0x%lx\n", T("slram: devname=%s, devstart=0x%lx, devlength=0x%lx\n",
devname, devstart, devlength); devname, devstart, devlength);
if ((devstart < 0) || (devlength < 0) || (devlength % SLRAM_BLK_SZ != 0)) { if (devlength % SLRAM_BLK_SZ != 0)
E("slram: Illegal start / length parameter.\n"); goto err_out;
return(-EINVAL);
}
if ((devstart = register_device(devname, devstart, devlength))){ if ((devstart = register_device(devname, devstart, devlength))){
unregister_devices(); unregister_devices();
return((int)devstart); return((int)devstart);
} }
return(0); return(0);
err_out:
E("slram: Illegal length parameter.\n");
return(-EINVAL);
} }
#ifndef MODULE #ifndef MODULE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment