lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <qjdn2rpln73nqozpkgd2z4haxym75mdtjbtnovip5j4fv4ao7m@f27hlfyi7flr>
Date: Mon, 26 Jan 2026 11:45:14 +0200
From: Ioana Ciornei <ioana.ciornei@....com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>, stuart.yoder@...escale.com, 
	agraf@...e.de, German.Rivera@...escale.com, gregkh@...uxfoundation.org, 
	linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org, stable@...r.kernel.org, 
	Su Hui <suhui@...china.com>, Christophe Leroy <chleroy@...nel.org>
Subject: Re: [PATCH v3] bus: fsl-mc: fix an error handling in
 fsl_mc_device_add()

On Sat, Jan 24, 2026 at 01:47:24PM +0300, Dan Carpenter wrote:
> On Sat, Jan 24, 2026 at 06:20:54PM +0800, Haoxiang Li wrote:
> > In fsl_mc_device_add(), device_initialize() is called first.
> > put_device() should be called to drop the reference if error
> > occurs. And other resources would be released via put_device
> > -> fsl_mc_device_release. So remove redundant kfree() in
> > error handling path.
> > 
> 
> It is true that we shouldn't free things directly after calling
> device_initialize().  I don't know the impact of this bug in
> real life.  Is it a leak?
> 
> > Fixes: bbf9d17d9875 ("staging: fsl-mc: Freescale Management Complex (fsl-mc) bus driver")
> > Cc: stable@...r.kernel.org
> > Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> > Closes: https://lore.kernel.org/all/b767348e-d89c-416e-acea-1ebbff3bea20@stanley.mountain/
> 
> Heh.  What was I even talking about when I wrote this???
> 
> In my head I remember the code as looking like this:
> https://lore.kernel.org/all/20251222074958.992911-1-lihaoxiang@isrc.iscas.ac.cn/
> But that's not the version of the code that I copy and pasted into my
> email.
> 
> The release function looks like this:
> 
> drivers/bus/fsl-mc/fsl-mc-bus.c
>    757  static void fsl_mc_device_release(struct device *dev)
>    758  {
>    759          struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
>    760  
>    761          kfree(mc_dev->regions);
>    762  
>    763          if (is_fsl_mc_bus_dprc(mc_dev))
>    764                  kfree(to_fsl_mc_bus(mc_dev));
>    765          else
>    766                  kfree(mc_dev);
>    767  }
> 
> The problem is that if this function call fails:
> 
> 	mc_dev->dev.type = fsl_mc_get_device_type(obj_desc->type);
> 
> Then the is_fsl_mc_bus_dprc() check might not work.  In the current
> code the to_fsl_mc_bus() pointer math is a no-op because mc_dev is
> the first struct member of mc_bus.  So it works for now, but it
> feels wrong.
> 
> The fsl_mc_get_device_type() function can't really fail in real
> life.
> 

I agree, the fsl_mc_get_device_type() function will not fail in real
life circumstances. And let's say that it fails, then we most certainly
are not handling a DPRC device, aka a bus device as checked by the
is_fsl_mc_bus_dprc() function. This means that fsl_mc_device_release()
will execute the 'kfree(mc_dev)' from the else branch as it was also in
the initial code under the error_cleanup_dev label.

Ioana

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ