From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org,
"Boris Brezillon" <bbrezillon@kernel.org>,
"Lucas Stach" <dev@lynxeye.de>,
"Dmitry Osipenko" <digetx@gmail.com>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Stefan Agner" <stefan@agner.ch>,
"Thierry Reding" <thierry.reding@kernel.org>
Subject: Re: [PATCH v2 15/58] mtd: rawnand: tegra: retain open-handle state on removal
Date: Tue, 10 Nov 2026 08:12:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-206575@kernel.org> (raw)
In-Reply-To: <20261110-submit-rawnand-retained-handle-lifetime-v1-v2-15-9137d08f05df@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: rawnand: tegra: cleanup helper and goto mixing in
tegra_nand_chips_init()
--
commit 1e69b67e008f7b424489423e4d072fb7d38b3000
Author: James Hilliard <james.hilliard1@gmail.com>
mtd: rawnand: tegra: retain open-handle state on removal
This commit switches the Tegra NAND chip and controller allocations to
reference-counted lifetime management so they are freed when the final MTD
references are released, and cleans up the child device node reference in
tegra_nand_chips_init().
> diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c
> index 1104d75b6cbe6..5130bee46d609 100644
> --- a/drivers/mtd/nand/raw/tegra_nand.c
> +++ b/drivers/mtd/nand/raw/tegra_nand.c
> @@ -1064,11 +1064,16 @@ static const struct nand_controller_ops tegra_nand_controller_ops = {
> .setup_interface = tegra_nand_setup_interface,
> };
>
> +static void tegra_nand_chip_release(struct nand_chip *chip)
> +{
> + kfree(container_of(chip, struct tegra_nand_chip, chip));
> +}
> +
> static int tegra_nand_chips_init(struct device *dev,
> struct tegra_nand_controller *ctrl)
> {
> struct device_node *np = dev->of_node;
> - struct device_node *np_nand;
> + struct device_node *np_nand __free(device_node) = NULL;
> int nsels, nchips = of_get_child_count(np);
> struct tegra_nand_chip *nand;
> struct mtd_info *mtd;
> @@ -1096,7 +1101,7 @@ static int tegra_nand_chips_init(struct device *dev,
> return ret;
> }
>
> - nand = devm_kzalloc(dev, sizeof(*nand), GFP_KERNEL);
> + nand = kzalloc_obj(*nand);
> if (!nand)
> return -ENOMEM;
>
> @@ -1107,7 +1112,7 @@ static int tegra_nand_chips_init(struct device *dev,
> if (IS_ERR(nand->wp_gpio)) {
> ret = PTR_ERR(nand->wp_gpio);
> dev_err(dev, "Failed to request WP GPIO: %d\n", ret);
> - return ret;
> + goto free_chip;
> }
>
> chip = &nand->chip;
> @@ -1127,20 +1132,35 @@ static int tegra_nand_chips_init(struct device *dev,
>
> ret = nand_scan(chip, 1);
> if (ret)
> - return ret;
> + goto free_chip;
>
> mtd_ooblayout_ecc(mtd, 0, &nand->ecc);
> + ret = nand_set_release(chip, tegra_nand_chip_release);
> + if (ret) {
> + nand_cleanup(chip);
> + goto free_chip;
> + }
>
> ret = mtd_device_register(mtd, NULL, 0);
> if (ret) {
> dev_err(dev, "Failed to register mtd device: %d\n", ret);
> - nand_cleanup(chip);
> + nand_disconnect(chip);
> + mtd_put_master(mtd);
> return ret;
> }
>
> ctrl->chip = chip;
>
> return 0;
> +
> +free_chip:
> + kfree(nand);
> + return ret;
> }
[Severity: Low]
This isn't a bug, but tegra_nand_chips_init() mixes __free(device_node) on
np_nand with a new goto free_chip unwinding path for nand, rather than
using either scope-based cleanup or goto unwinding consistently across the
function. Also, np_nand is declared with __free(device_node) = NULL at
the top of the function instead of being defined and initialized in a
single statement where of_get_next_child() is called.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110-submit-rawnand-retained-handle-lifetime-v1-v2-0-9137d08f05df@gmail.com?part=15
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-10 8:12 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 7:44 [PATCH v2 00/58] mtd: rawnand: retain chip and controller state across removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 01/58] nvmem: retain provider context through final device release James Hilliard
2026-11-10 7:44 ` [PATCH v2 02/58] driver core: retain the owner of device release callbacks James Hilliard
2026-11-10 18:50 ` Greg Kroah-Hartman
2026-11-10 7:44 ` [PATCH v2 03/58] mtd: add opt-in lifetime ownership for backing objects James Hilliard
2026-11-10 7:44 ` [PATCH v2 04/58] mtd: retain virtual concatenations across component removal James Hilliard
2026-11-10 8:14 ` sashiko-bot
2026-11-10 7:44 ` [PATCH v2 05/58] mtd: rawnand: separate hardware disconnection from cleanup James Hilliard
2026-11-10 7:44 ` [PATCH v2 06/58] mtd: rawnand: share retained chip and controller ownership James Hilliard
2026-11-10 7:44 ` [PATCH v2 07/58] mtd: rawnand: sunxi: retain chip state until the final MTD put James Hilliard
2026-11-10 7:44 ` [PATCH v2 08/58] mtd: rawnand: plat_nand: retain open-handle state on removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 09/58] mtd: rawnand: gpio: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 10/58] mtd: rawnand: stm32_fmc2: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 11/58] mtd: rawnand: denali: retain chips across controller removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 12/58] mtd: rawnand: arasan: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 13/58] mtd: rawnand: mxic: retain open-handle state on removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 14/58] mtd: rawnand: intel: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 15/58] mtd: rawnand: tegra: " James Hilliard
2026-11-10 8:12 ` sashiko-bot [this message]
2026-11-10 7:44 ` [PATCH v2 16/58] mtd: rawnand: mtk: retain chips across controller removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 17/58] mtd: rawnand: rockchip: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 18/58] mtd: rawnand: atmel: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 19/58] mtd: rawnand: orion: retain open-handle state on removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 20/58] mtd: rawnand: socrates: " James Hilliard
2026-11-10 8:20 ` sashiko-bot
2026-11-10 7:44 ` [PATCH v2 21/58] mtd: rawnand: fsl_upm: " James Hilliard
2026-11-10 8:22 ` sashiko-bot
2026-11-10 7:44 ` [PATCH v2 22/58] mtd: rawnand: pasemi: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 23/58] mtd: rawnand: ams-delta: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 24/58] mtd: rawnand: xway: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 25/58] mtd: rawnand: hisi504: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 26/58] mtd: rawnand: vf610: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 27/58] mtd: rawnand: technologic: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 28/58] mtd: rawnand: loongson: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 29/58] mtd: rawnand: ma35d1: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 30/58] mtd: rawnand: pl35x: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 31/58] mtd: rawnand: mxc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 32/58] mtd: rawnand: fsmc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 33/58] mtd: rawnand: gpmi: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 34/58] mtd: rawnand: omap2: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 35/58] mtd: rawnand: marvell: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 36/58] mtd: rawnand: renesas: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 37/58] mtd: rawnand: meson: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 38/58] mtd: rawnand: cadence: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 39/58] mtd: rawnand: qcom: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 40/58] mtd: rawnand: cafe: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 41/58] mtd: rawnand: brcmnand: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 42/58] mtd: rawnand: au1550nd: retain chip state across removal James Hilliard
2026-11-10 7:44 ` [PATCH v2 43/58] mtd: rawnand: sharpsl: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 44/58] mtd: rawnand: davinci: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 45/58] mtd: rawnand: sh_flctl: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 46/58] mtd: rawnand: lpc32xx_slc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 47/58] mtd: rawnand: lpc32xx_mlc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 48/58] mtd: rawnand: ndfc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 49/58] mtd: rawnand: txx9ndfmc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 50/58] mtd: rawnand: ingenic: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 51/58] mtd: rawnand: mpc5121: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 52/58] mtd: rawnand: bcm47xxnflash: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 53/58] mtd: rawnand: fsl_elbc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 54/58] mtd: rawnand: fsl_ifc: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 55/58] mtd: rawnand: r852: " James Hilliard
2026-11-10 7:44 ` [PATCH v2 56/58] mtd: rawnand: nandsim: " James Hilliard
2026-11-10 7:45 ` [PATCH v2 57/58] mtd: rawnand: cs553x: " James Hilliard
2026-11-10 7:45 ` [PATCH v2 58/58] mtd: rawnand: diskonchip: " James Hilliard
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=sashiko-outbox-206575@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bbrezillon@kernel.org \
--cc=dev@lynxeye.de \
--cc=digetx@gmail.com \
--cc=james.hilliard1@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stefan@agner.ch \
--cc=thierry.reding@kernel.org \
--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