From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-mtd@lists.infradead.org,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCHv2] mtd: rawnand: fsl_ifc: allocate shared ctrl with devm_kzalloc
Date: Tue, 08 Sep 2026 11:37:11 +0200 [thread overview]
Message-ID: <87h5k0ulrs.fsf@bootlin.com> (raw)
In-Reply-To: <20260908060111.41244-1-rosenp@gmail.com> (Rosen Penev's message of "Mon, 7 Sep 2026 23:01:11 -0700")
On 07/09/2026 at 23:01:11 -07, Rosen Penev <rosenp@gmail.com> wrote:
> Allocate the shared fsl_ifc_nand_ctrl structure against the controller
> device, which outlives all NAND child devices, so it is freed
> automatically. This drops the manual kfree() and the broken chip
> counter that was decremented in remove() but never incremented
> anywhere, leaking the structure and leaving the freed pointer in
> ctrl->nand on re-probe.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> v2: rebase.
> drivers/mtd/nand/raw/fsl_ifc_nand.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c
> index a88ac2cfaccd..4c2d95461c2e 100644
> --- a/drivers/mtd/nand/raw/fsl_ifc_nand.c
> +++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c
> @@ -50,7 +50,6 @@ struct fsl_ifc_nand_ctrl {
> unsigned int index; /* Pointer to next byte to 'read' */
> unsigned int oob; /* Non zero if operating on OOB data */
> unsigned int eccread; /* Non zero for a full-page ECC read */
> - unsigned int counter; /* counter for the initializations */
> unsigned int max_bitflips; /* Saved during READ0 cmd */
> };
>
> @@ -1033,15 +1032,13 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
>
> mutex_lock(&fsl_ifc_nand_mutex);
> if (!fsl_ifc_ctrl_dev->nand) {
> - ifc_nand_ctrl = kzalloc_obj(*ifc_nand_ctrl);
> + ifc_nand_ctrl = devm_kzalloc(fsl_ifc_ctrl_dev->dev, sizeof(*ifc_nand_ctrl),
> + GFP_KERNEL);
This is a global object. I don't get why it's global. But it seems not
relevant to tie with ctrl_dev->dev (see Sashiko report). Can you please
go one step further in this cleanup?
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-09-08 9:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:01 [PATCHv2] mtd: rawnand: fsl_ifc: allocate shared ctrl with devm_kzalloc Rosen Penev
2026-09-08 9:37 ` Miquel Raynal [this message]
2026-09-08 19:12 ` Rosen Penev
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=87h5k0ulrs.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=rosenp@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.