Re: [PATCH] zram: compression algorithms name use static fields
From: Sergey Senozhatsky
Date: Thu Feb 26 2026 - 03:23:14 EST
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?