All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Moteen Shah" <m-shah@ti.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/4] soc: ti: Add TDA54 SCM configuration syscon support
Date: Thu, 12 Nov 2026 08:36:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-210748@kernel.org> (raw)
In-Reply-To: <20261112081047.1550471-5-m-shah@ti.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] soc: ti: missing linux/soc/ti/k3-socinfo.h breaks build in
  tda54-mcu-sysconf.c
- [High] soc: ti: use-after-free on module unload in
  tda54_scm_conf_probe()
--

commit 1413c74caebaef4be4a2098e4a72bde6c5e8dc93
Author: Moteen Shah <m-shah@ti.com>

soc: ti: Add TDA54 SCM configuration syscon support

This commit adds the TDA54 SCM configuration syscon driver to provide
proxy-based regmap access to the SCM register space and register TDA54
SoC identification information via k3-socinfo.

> diff --git a/drivers/soc/ti/tda54-mcu-sysconf.c b/drivers/soc/ti/tda54-mcu-sysconf.c
> new file mode 100644
> index 0000000000000..3ef82e737d095
> --- /dev/null
> +++ b/drivers/soc/ti/tda54-mcu-sysconf.c
> @@ -0,0 +1,217 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * TDA54 SCM Configuration syscon driver
> + *
> + * Copyright (C) 2026 Texas Instruments Incorporated - https://www.ti.com/
> + */
> +#include <linux/bitfield.h>
> +#include <linux/bitops.h>
> +#include <linux/io.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/soc/ti/k3-socinfo.h>

[Severity: High]
Was include/linux/soc/ti/k3-socinfo.h omitted from earlier commit
"soc: ti: k3-socinfo: Export SoC registration helper"?  Because that
header is not in the tree and k3_socinfo_register() has no prototype,
building with CONFIG_TI_TDA54_MCU_SYSCONF or CONFIG_TI_K3_SOCINFO enabled
fails.

[ ... ]

> +	regmap = devm_regmap_init(dev, NULL, scm, &tda54_scm_conf_regmap_cfg);
> +	if (IS_ERR(regmap))
> +		return PTR_ERR(regmap);
> +
> +	writel(TDA54_SCM_CONF_LOCK_KICK0_UNLOCK_VAL, scm->base + scm->pdata->lock_offset);
> +	writel(TDA54_SCM_CONF_LOCK_KICK1_UNLOCK_VAL, scm->base + scm->pdata->lock_offset + 4);
> +
> +	/*
> +	 * There is no way to unregister a syscon regmap, so publish it only
> +	 * once nothing else in probe can fail.
> +	 */
> +	ret = of_syscon_register_regmap(dev->of_node, regmap);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to register syscon regmap\n");

[ ... ]

> +static struct platform_driver tda54_scm_conf_driver = {
> +	.probe = tda54_scm_conf_probe,
> +	.driver = {
> +		.name = "k3-tda54-scm-conf",
> +		.of_match_table = tda54_scm_conf_of_match,
> +		.suppress_bind_attrs = true,
> +	},
> +};
> +
> +module_platform_driver(tda54_scm_conf_driver);

[Severity: High]
As reported by Andrew Davis on v1 [1], can unloading this module cause a
use-after-free when consumers access the syscon regmap?

TI_TDA54_MCU_SYSCONF is tristate (default m on ARCH_K3) and
module_platform_driver() generates a module_exit callback, while
.suppress_bind_attrs only removes the sysfs bind/unbind files.  Unloading
the module unbinds the device, frees the devm-managed regmap, ioremap, and
scm context, and unmaps the regmap read/write callbacks, while the global
syscon_list in drivers/mfd/syscon.c retains a dangling pointer to regmap
(and any later reload fails in of_syscon_register_regmap() with -EEXIST).
Registering the driver with builtin_platform_driver() (or module_init()
without module_exit()) keeps the module loadable while preventing unload.

[1] https://lore.kernel.org/r/b5bc4c10-b364-4992-ae84-63e5b86771a3@ti.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112081047.1550471-1-m-shah@ti.com?part=4

  reply	other threads:[~2026-11-12  8:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  8:10 [PATCH v3 0/4] soc: ti: Add TDA54 SCM configuration syscon support Moteen Shah
2026-11-12  8:10 ` [PATCH v3 1/4] dt-bindings: soc: ti: Document the ti,tda54-mcu-scm-conf Moteen Shah
2026-11-12  8:23   ` sashiko-bot
2026-11-12  8:10 ` [PATCH v3 2/4] soc: ti: k3-socinfo: Use device managed allocations and unregistration Moteen Shah
2026-11-12  8:10 ` [PATCH v3 3/4] soc: ti: k3-socinfo: Export SoC registration helper Moteen Shah
2026-11-12  8:19   ` sashiko-bot
2026-11-12  8:32     ` Moteen Shah
2026-11-12 17:21   ` kernel test robot
2026-11-12  8:10 ` [PATCH v3 4/4] soc: ti: Add TDA54 SCM configuration syscon support Moteen Shah
2026-11-12  8:36   ` sashiko-bot [this message]
2026-11-12 16:16   ` kernel test robot

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-210748@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=m-shah@ti.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.