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

haoqin huang <[email protected]> Tue, 4 Aug 2026 15:15:56 +0800
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <CAEjiKSkWPM3viBXNnFniukc9-OxXPgbmCbmxy-+7vrwVcog7yg@mail.gmail.com>
On Tue, Aug 4, 2026 at 1:32=E2=80=AFPM Sergey Senozhatsky
<[email protected]> wrote:
>
> On (26/08/03 22:12), Haoqin Huang wrote:
> [..]
> > @@ -1700,8 +1700,12 @@ static int comp_params_store(struct zram *zram, =
u32 prio, s32 level,
> >                                               INT_MAX,
> >                                               NULL,
> >                                               READING_POLICY);
> > -             if (sz < 0)
> > +             if (sz <=3D 0) {
> > +                     pr_err("failed to load dictionary %s (err=3D%zd)\=
n",
> > +                            dict_path, sz);
>
> So for empty file this will read
>
>         "failed to load dictionary foo-bar (err=3D0)"
>
> which might be confusing.  I wonder if we want to separate these two:
>
>         if (sz < 0) {
>                 pr_err("failed to load dictionary %s (err=3D%zd)\n",
>                        dict_path, sz);
>                 return sz;
>         }
>         if (sz =3D=3D 0) {
>                 pr_err("failed to load dictionary %s (empty file)\n",
>                        dict_path);
>                 return -EINVAL;
>         }

Good idea, much clearer. I will split them in v6. Thanks.