[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230103030119.1496358-1-senozhatsky@chromium.org>
Date: Tue, 3 Jan 2023 12:01:19 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Minchan Kim <minchan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Sergey Senozhatsky <senozhatsky@...omium.org>
Subject: [PATCH] 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=`.
Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
---
drivers/block/zram/zram_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e290d6d97047..70c412eb6c1f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1140,7 +1140,7 @@ static ssize_t recomp_algorithm_store(struct device *dev,
while (*args) {
args = next_arg(args, ¶m, &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, ¶m, &val);
- if (!*val)
+ if (!val || !*val)
return -EINVAL;
if (!strcmp(param, "type")) {
--
2.39.0.314.g84b9a713c41-goog
Powered by blists - more mailing lists