mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
zram: reject zero-size dictionary
kernel_read_file_from_path() already rejects empty files (i_size <= 0) and returns -EINVAL, but the current implementation only checks for sz < 0 without logging any information. Use sz == 0 to reject the zero-size case and print distinct error messages for each failure type. Link: https://lore.kernel.org/20260804093841.67920-3-haoqinhuang7@gmail.com Signed-off-by: Haoqin Huang <haoqinhuang@tencent.com> Signed-off-by: Rongwei Wang <zigiwang@tencent.com> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Tested-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: David Sterba <dsterba@suse.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Minchan Kim <minchan@kernel.org> Cc: Nick Terrell <terrelln@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
45214458d6
commit
6dc404d433
|
|
@ -1700,8 +1700,16 @@ static int comp_params_store(struct zram *zram, u32 prio, s32 level,
|
|||
INT_MAX,
|
||||
NULL,
|
||||
READING_POLICY);
|
||||
if (sz < 0)
|
||||
if (sz < 0) {
|
||||
pr_err("failed to load dictionary %s (err=%zd)\n",
|
||||
dict_path, sz);
|
||||
return sz;
|
||||
}
|
||||
if (sz == 0) {
|
||||
pr_err("failed to load dictionary %s (empty file)\n",
|
||||
dict_path);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
zram->params[prio].dict_sz = sz;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user