i.MX SoC Changes for v7.3

- Fix OF/device_node reference count leaks in imx_src_init(),
   imx7_src_init(), and the AVIC interrupt controller driver
 - Drop obsolete/unused declarations from `arch/arm/mach-imx/common.h`
 - firmware: imx: scu: Refactor mailbox channel management to use a
   per-instance handle instead of a global one
 - firmware: imx: sm-misc: Add NULL check for `kmalloc` return value in
   syslog_show
 - soc: imx9: Add error handling for `devm_kasprintf` return value
 -----BEGIN PGP SIGNATURE-----
 
 iQHFBAABCgAvFiEEJS45w2QNr0ezLVaoNF3oRQ23YkwFAmpqVNkRHGZyYW5rLmxp
 QG54cC5jb20ACgkQNF3oRQ23Ykww1gv/e6t/433X0gei3wrBnqMGn+eGrW278YBK
 rFsTe8/UZgQpH689WHdsKRhgLPaAi9Tm2i8plyPfSZTNxiIvp564kBdpwi3BvpwI
 /83s0vRC+6tw4ngyR1awFfr8AP0F9KxSdk7KfWjDqGYXZ5pgIMXhch+196undVf+
 8wL5c2WWlBSkIaakQwhTEcmR43mkFHoKh9k3K/ub0PceqxdzodvlqcqaxqeVXLyC
 ZyQOR5mbVBTFLFtIj/JBKZQb6GsqsH41Yifk4udEtknx3mjoWMBhwqLiWvToJICo
 KkEyg7Dc5JlQ6CMp+uEjji5FpckRsYjMf/NfSYf7lDuUMJf+j7IHz14DnBh4b0g0
 gy6nq3vEBo/RpfaVe8v38j1IaA90gx7BJxLbh90+vJG4XvgP5tf5apTyyZ+9ecTZ
 Qd9Iz/TIbarD6sShBm0KIfsmS0Js+r/2yWt4rUDwDJZh/bYYMcbUJcfSM8Fd/RUV
 achgxY/zy88Vx65vrlOmL0CK8OoFcGra
 =uGEB
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmprEtoACgkQmmx57+YA
 GNma9A//ec/5uPQplFVfWrIMD1RwgpddbckUrvgulmPAsQ2rSnWma+rQdR/yXoZS
 sw5fP/0ebPpDMRojHcB7DGqEJ9f2IJJr+orpbBHGT4Cbznqq4+ZxyG7xvmrcojxW
 7rEHDSi0/qmYvxNhs3iXiWgUGXrpAMGBm/yw74I/6+zxAT10VtasLBXOlyPHagn0
 qxomPQKGSNlNhCdpJXaXu6fyNJohY5lwpxQLTEsYQPQksJQg9xe1DcIu5WOJHuVa
 Q2er7vzDf5ARChzGhJic0zxpnIX/UDRyGr6716Ay94DwELl6mdKCZvpBmdDpASPs
 P8BD9jVThVuH8bZonfhSlBIyhLNkF4aXKG/PG7nq4GMYrBmkzikSrBCY2kn4nKB5
 NVNpjAPTiabOw0oWtszk26Jnav6oMrw4RN4/oh3eKIEvoIfoMw9fKHrqLC9eXULo
 /joJQotoqmxm5U3mRY5K9n/FmUNPkbJwko9663ymk9vyLTkkwFnRV/zjeGXmNpda
 YxEH+9zCpUNK1nAvVtgIsiOJU+GXDiy0zJ8f7odk6uW2iQASpVEcBlf7m3+bM3rV
 +5y7elg/VUXqhYkGuIe9/fS0/jcW6Je2YD/U5czmJwfFURYuIzMJPbv1wf9Ato9R
 6UYGYnaE4DWaLzDNCGUXIG2GTtJLuZJhIZsULzg0CuoloJ7KEN0=
 =4zKa
 -----END PGP SIGNATURE-----

Merge tag 'imx-soc-7.3' of https://git.kernel.org/pub/scm/linux/kernel/git/frank.li/linux into soc/arm

i.MX SoC Changes for v7.3

- Fix OF/device_node reference count leaks in imx_src_init(),
  imx7_src_init(), and the AVIC interrupt controller driver
- Drop obsolete/unused declarations from `arch/arm/mach-imx/common.h`
- firmware: imx: scu: Refactor mailbox channel management to use a
  per-instance handle instead of a global one
- firmware: imx: sm-misc: Add NULL check for `kmalloc` return value in
  syslog_show
- soc: imx9: Add error handling for `devm_kasprintf` return value

* tag 'imx-soc-7.3' of https://git.kernel.org/pub/scm/linux/kernel/git/frank.li/linux:
  firmware: imx: scu: manage mailbox channels and global handle
  soc: imx9: devm_kasprintf error handling
  ARM: imx: Drop obsolete stuff from common.h
  firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
  ARM: imx: fix device_node refcount leaks in imx7_src_init()
  ARM: imx: fix device_node refcount leak in imx_src_init()
  ARM: imx: avic: Fix OF node reference leaks

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2026-07-30 11:01:01 +02:00
commit 7c8af4b5b6
7 changed files with 41 additions and 16 deletions

View File

@ -173,6 +173,7 @@ static void __init mxc_init_irq(void __iomem *irqbase)
np = of_find_compatible_node(NULL, NULL, "fsl,imx25-ccm");
mx25_ccm_base = of_iomap(np, 0);
of_node_put(np);
if (mx25_ccm_base) {
/*
@ -203,6 +204,7 @@ static void __init mxc_init_irq(void __iomem *irqbase)
np = of_find_compatible_node(NULL, NULL, "fsl,avic");
domain = irq_domain_create_legacy(of_fwnode_handle(np), AVIC_NUM_IRQS, irq_base, 0,
&irq_domain_simple_ops, NULL);
of_node_put(np);
WARN_ON(!domain);
for (i = 0; i < AVIC_NUM_IRQS / 32; i++, irq_base += 32)

View File

@ -14,23 +14,16 @@ struct platform_device;
struct pt_regs;
struct clk;
struct device_node;
enum mxc_cpu_pwr_mode;
struct of_device_id;
void mx31_map_io(void);
void mx35_map_io(void);
void imx21_init_early(void);
void imx31_init_early(void);
void imx35_init_early(void);
void mx31_init_irq(void);
void mx35_init_irq(void);
void mxc_set_cpu_type(unsigned int type);
void mxc_restart(enum reboot_mode, const char *);
void mxc_arch_reset_init(void __iomem *);
void imx1_reset_init(void __iomem *);
void imx_set_aips(void __iomem *);
void imx_aips_allow_unprivileged_access(const char *compat);
int mxc_device_init(void);
void imx_set_soc_revision(unsigned int rev);
void imx_init_revision_from_anatop(void);
void imx6_enable_rbc(bool enable);

View File

@ -171,6 +171,7 @@ void __init imx_src_init(void)
if (!np)
return;
src_base = of_iomap(np, 0);
of_node_put(np);
WARN_ON(!src_base);
/*
@ -195,6 +196,7 @@ void __init imx7_src_init(void)
return;
src_base = of_iomap(np, 0);
of_node_put(np);
if (!src_base)
return;
@ -203,6 +205,7 @@ void __init imx7_src_init(void)
return;
gpc_base = of_iomap(np, 0);
of_node_put(np);
if (!gpc_base)
return;
}

View File

@ -74,14 +74,6 @@ void __init mxc_arch_reset_init(void __iomem *base)
clk_prepare(wdog_clk);
}
#ifdef CONFIG_SOC_IMX1
void __init imx1_reset_init(void __iomem *base)
{
wcr_enable = (1 << 0);
mxc_arch_reset_init(base);
}
#endif
#ifdef CONFIG_CACHE_L2X0
void __init imx_init_l2cache(void)
{

View File

@ -82,6 +82,17 @@ static int imx_sc_linux_errmap[IMX_SC_ERR_LAST] = {
static struct imx_sc_ipc *imx_sc_ipc_handle;
static void imx_scu_free_mbox_chan(void *data)
{
mbox_free_channel(data);
}
static void imx_scu_clear_handle(void *data)
{
if (imx_sc_ipc_handle == data)
imx_sc_ipc_handle = NULL;
}
static inline int imx_sc_to_linux_errno(int errno)
{
if (errno >= IMX_SC_ERR_NONE && errno < IMX_SC_ERR_LAST)
@ -321,6 +332,11 @@ static int imx_scu_probe(struct platform_device *pdev)
dev_dbg(dev, "request mbox chan %s\n", chan_name);
/* chan_name is not used anymore by framework */
kfree(chan_name);
ret = devm_add_action_or_reset(dev, imx_scu_free_mbox_chan,
sc_chan->ch);
if (ret)
return ret;
}
sc_ipc->dev = dev;
@ -330,6 +346,9 @@ static int imx_scu_probe(struct platform_device *pdev)
init_completion(&sc_ipc->done);
imx_sc_ipc_handle = sc_ipc;
ret = devm_add_action_or_reset(dev, imx_scu_clear_handle, sc_ipc);
if (ret)
return ret;
ret = imx_scu_soc_init(dev);
if (ret)
@ -342,7 +361,11 @@ static int imx_scu_probe(struct platform_device *pdev)
dev_info(dev, "NXP i.MX SCU Initialized\n");
return devm_of_platform_populate(dev);
ret = devm_of_platform_populate(dev);
if (ret)
of_platform_depopulate(dev);
return ret;
}
static const struct of_device_id imx_scu_match[] = {

View File

@ -79,6 +79,9 @@ static int syslog_show(struct seq_file *file, void *priv)
u16 size = SZ_4K / 4;
int ret;
if (!syslog)
return -ENOMEM;
if (!ph)
return -ENODEV;

View File

@ -35,6 +35,8 @@ static int imx9_soc_probe(struct platform_device *pdev)
return dev_err_probe(dev, err, "%s: missing model property\n", __func__);
attr->family = devm_kasprintf(dev, GFP_KERNEL, "Freescale i.MX");
if (!attr->family)
return -ENOMEM;
/*
* Retrieve the soc id, rev & uid info:
@ -52,11 +54,18 @@ static int imx9_soc_probe(struct platform_device *pdev)
rev_minor = SOC_REV_MINOR(res.a1);
attr->soc_id = devm_kasprintf(dev, GFP_KERNEL, "i.MX%2x", soc_id);
if (!attr->soc_id)
return -ENOMEM;
attr->revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d", rev_major, rev_minor);
if (!attr->revision)
return -ENOMEM;
uid127_64 = res.a2;
uid63_0 = res.a3;
attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llx%016llx", uid127_64, uid63_0);
if (!attr->serial_number)
return -ENOMEM;
sdev = soc_device_register(attr);
if (IS_ERR(sdev))