From: gao xu <gaoxu2@honor.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>, Jens Axboe <axboe@kernel.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"surenb@google.com" <surenb@google.com>,
zhouxiaolong <zhouxiaolong9@honor.com>
Subject: RE: [PATCH] zram: compression algorithms name use static fields
Date: Thu, 26 Feb 2026 11:48:45 +0000 [thread overview]
Message-ID: <0058c37421d1470597a599eaddb09a60@honor.com> (raw)
In-Reply-To: <uizrrkcxvs5dnqn7tosot564gjymgzsuypdtjj4w6wpfxfoxvm@a6quz7px4ssu>
>
> On (26/02/26 07:50), gao xu wrote:
> [..]
> > @@ -1648,6 +1644,7 @@ static int __comp_algorithm_store(struct zram
> *zram, u32 prio, const char *buf)
> > {
> > char *compressor;
> > size_t sz;
> > + const char *alg;
> >
> > sz = strlen(buf);
> > if (sz >= ZRAM_MAX_ALGO_NAME_SZ)
> > @@ -1661,10 +1658,10 @@ static int __comp_algorithm_store(struct zram
> *zram, u32 prio, const char *buf)
> > if (sz > 0 && compressor[sz - 1] == '\n')
> > compressor[sz - 1] = 0x00;
> >
> > - if (!zcomp_available_algorithm(compressor)) {
> > - kfree(compressor);
> > + alg = zcomp_lookup_backend_name(compressor);
> > + kfree(compressor);
>
> I guess we don't really need to kstrdup() the compressor name? Lookup
> uses sysfs_streq(), which should take care of terminating \n, so I assume
> we can just pass `buf` to zcomp_lookup_backend_name() directly?
>
> I guess we also can get rid of `[sz - 1] == '\n'` thing?
I've verified your suggested changes and haven't found any issues.
I will incorporate this modification into the v2 version.
next prev parent reply other threads:[~2026-02-26 11:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 7:50 [PATCH] zram: compression algorithms name use static fields gao xu
2026-02-26 8:23 ` Sergey Senozhatsky
2026-02-26 11:48 ` gao xu [this message]
2026-02-26 10:27 ` Sergey Senozhatsky
2026-02-26 11:51 ` gao xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0058c37421d1470597a599eaddb09a60@honor.com \
--to=gaoxu2@honor.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=surenb@google.com \
--cc=zhouxiaolong9@honor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox