Re: [PATCH v4 2/4] zram: reject zero-size dictionary

From: Sergey Senozhatsky

Date: Thu Jul 30 2026 - 03:29:45 EST


On (26/07/30 14:01), Haoqin Huang wrote:
> 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 cover the
> zero-size case and print an error message if dictionary loading fails.
>
> Signed-off-by: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>
> Signed-off-by: Rongwei Wang <zigiwang@xxxxxxxxxxx>
> ---
> drivers/block/zram/zram_drv.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index ace65c586072..0223fd83bbba 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1709,8 +1709,11 @@ 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("zram: failed to load dictionary %s (err=%zd)\n",

This leads to a double-prefixed line "zram: zram: " as zram already
defines pr_fmt().