On Wed, Mar 19, 2025 at 11:23:04AM +0800, Miaoqian Lin wrote: > Fix a reference count leak in slave_show() by properly putting the device > reference obtained from device_find_any_child(). ... > 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); put_device(child); return sysfs_emit(buf, "%s\n", NULL); No variable needed. -- With Best Regards, Andy Shevchenko