From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Dan Carpenter" <error27@gmail.com>,
"Luca Ceresoli" <luca.ceresoli@bootlin.com>
Cc: "Harshit Mogalapalli" <harshit.m.mogalapalli@oracle.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Amit Kumar Mahapatra" <amit.kumar-mahapatra@amd.com>,
<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] mtd: virt_concat: fix use-after-free in mtd_virt_concat_destroy_joins()
Date: Tue, 16 Jun 2026 22:31:28 +0200 [thread overview]
Message-ID: <DJARC89F2VJR.1EDEQ27GSDAK6@bootlin.com> (raw)
In-Reply-To: <ajEhuS8xwcX1AA_I@stanley.mountain>
On Tue Jun 16, 2026 at 12:13 PM CEST, Dan Carpenter wrote:
> On Tue, Jun 16, 2026 at 11:51:53AM +0200, Luca Ceresoli wrote:
>> Issue 2: in mtd_virt_concat_destroy_joins():
>>
>> list_for_each_entry_safe(item, tmp, &concat_node_list, head) {
>> mtd = &item->concat->mtd; [0]
>> if (item->concat) { [1]
>>
>> At line [0] we dereference item->concat, but at line [1] we apparently
>> handle the case where item->concat can be NULL. Either [1] is always true
>> and we can remove the if(), or [1] can be false, so [0] is a bug and should
>> probably be moved to inside the if().
>
> That's not a dereference on line 0, it's pointer math. So the code
> works. But a lot of people find the distinction confusing.
Ah, indeed, you are right on both aspects: it's just pointer math (not a
bug) + it is confusing code.
So moving [0] inside the if() would be a readability improvement IMO, but
definitely not a bugfix.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-06-16 20:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 8:10 [PATCH] mtd: virt_concat: fix use-after-free in mtd_virt_concat_destroy_joins() Harshit Mogalapalli
2026-06-16 9:51 ` Luca Ceresoli
2026-06-16 10:13 ` Dan Carpenter
2026-06-16 20:31 ` Luca Ceresoli [this message]
2026-06-16 12:25 ` Harshit Mogalapalli
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=DJARC89F2VJR.1EDEQ27GSDAK6@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=amit.kumar-mahapatra@amd.com \
--cc=error27@gmail.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.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