Re: [PATCH] spi: Fix reference count leak in slave_show()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 19, 2025 at 12:44:33PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 19, 2025 at 11:23:04AM +0800, Miaoqian Lin wrote:

...

> >  	struct device *child;
> > +	int ret;
> >  
> >  	child = device_find_any_child(&ctlr->dev);
> > -	return sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias : NULL);
> > +	ret = sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias : NULL);
> > +	put_device(child);
> > +
> > +	return ret;
> 
> Can be written better in case of NULL:
> 
> 	child = device_find_any_child(&ctlr->dev);
> 	if (child)
> 		return sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias);

Of course this has to be

		return sysfs_emit(buf, "%s\n", to_spi_device(child)->modalias);

> 
> 	put_device(child);
> 	return sysfs_emit(buf, "%s\n", NULL);
> 
> No variable needed.

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux