From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Andrey Skvortsov <andrej.skvortzov@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>,
Minchan Kim <minchan@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] zram: don't free statically defined names
Date: Mon, 23 Sep 2024 18:47:46 +0200 [thread overview]
Message-ID: <9680600d-0bea-4339-bbf5-0ccc50d13551@wanadoo.fr> (raw)
In-Reply-To: <ZvGar7f5IcMiFzKk@skv.local>
Le 23/09/2024 à 18:43, Andrey Skvortsov a écrit :
> On 24-09-24 01:07, Sergey Senozhatsky wrote:
>> On (24/09/23 18:55), Andrey Skvortsov wrote:
>> [..]
>>>> Ugh, I know what's happening. You don't have CONFIG_ZRAM_MULTI_COMP
>>>> so that ZRAM_PRIMARY_COMP and ZRAM_SECONDARY_COMP are the same thing.
>>>> Yeah, that all makes sense now, I haven't thought about it.
>>>
>>> yes, I don't have CONFIG_ZRAM_MULTI_COMP set. I'll include your
>>> comment into commit description for v2.
>>
>> Thanks.
>>
>> Can you do it something like the diff below? Let's iterate
>> ->comp_algs from ZRAM_PRIMARY_COMP. I don't really mind the
>> "Do not free statically defined" comment, up to you.
>>
>> And the commit message probably can stay that: on !CONFIG_ZRAM_MULTI_COMP
>> systems ZRAM_SECONDARY_COMP can hold default_compressor, because it's
>> the same offset as ZRAM_PRIMARY_COMP, so we need to make sure that we
>> don't attempt to kfree() the statically defined comp name.
>>
>> ---
>>
>> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
>> index c3d245617083..ad9c9bc3ccfc 100644
>> --- a/drivers/block/zram/zram_drv.c
>> +++ b/drivers/block/zram/zram_drv.c
>> @@ -2115,8 +2115,10 @@ static void zram_destroy_comps(struct zram *zram)
>> zram->num_active_comps--;
>> }
>>
>> - for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
>> - kfree(zram->comp_algs[prio]);
>> + for (prio = ZRAM_PRIMARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
>> + /* Do not free statically defined compression algorithms */
>> + if (zram->comp_algs[prio] != default_compressor)
>> + kfree(zram->comp_algs[prio]);
>> zram->comp_algs[prio] = NULL;
>> }
> Sorry, I've seen you comment after I've sent v2. I'll do this in v3.
>
Hi,
maybe kfree_const() to catch potential future cases and simplify code?
CJ
prev parent reply other threads:[~2024-09-23 16:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-23 8:02 [PATCH] zram: don't free statically defined names Andrey Skvortsov
2024-09-23 15:34 ` Sergey Senozhatsky
2024-09-23 15:47 ` Sergey Senozhatsky
2024-09-23 15:55 ` Andrey Skvortsov
2024-09-23 16:07 ` Sergey Senozhatsky
2024-09-23 16:43 ` Andrey Skvortsov
2024-09-23 16:47 ` Christophe JAILLET [this message]
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=9680600d-0bea-4339-bbf5-0ccc50d13551@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=akpm@linux-foundation.org \
--cc=andrej.skvortzov@gmail.com \
--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=stable@vger.kernel.org \
--cc=venkat88@linux.vnet.ibm.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