Commit df32de14 authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Andrew Morton

zram: correctly handle all next_arg() cases

When supplied buffer does not have assignment sign next_arg() sets `val`
pointer to NULL, so we cannot dereference it.  Add a NULL pointer test to
handle `param` case, in addition to `*val` test, which handles cases when
param has no value assigned to it: `param=`.

Link: https://lkml.kernel.org/r/20230103030119.1496358-1-senozhatsky@chromium.orgSigned-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4b89a37d
......@@ -1140,7 +1140,7 @@ static ssize_t recomp_algorithm_store(struct device *dev,
while (*args) {
args = next_arg(args, &param, &val);
if (!*val)
if (!val || !*val)
return -EINVAL;
if (!strcmp(param, "algo")) {
......@@ -1824,7 +1824,7 @@ static ssize_t recompress_store(struct device *dev,
while (*args) {
args = next_arg(args, &param, &val);
if (!*val)
if (!val || !*val)
return -EINVAL;
if (!strcmp(param, "type")) {
......
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