On Wed, Jul 22, 2026 at 02:15:55AM +0300, Vladimir Oltean wrote: > fsl_guts_init() is about to get much more complicated and the central > error handling procedure cannot scale in its current design, unless we > add a lot of "if" conditions to detect what has been allocated and what > hasn't. > > Currently the code relies on the fact that kfree(NULL) is safe, but this > doesn't scale to the case where "soc_dev_attr" itself is NULL, because > this would dereference "soc_dev_attr->family" and friends of a NULL > pointer. > > Convert to the more typical error handling pattern where the teardown is > in the strict reverse order of setup, and a teardown step is only called > if its corresponding setup step was executed. > > At the same time, maintain the optionality of soc_dev_attr->serial_number > by not checking whether that kasprintf() has returned NULL. In the error > path, kfree(NULL) is safe, so we don't need to add an "if" condition for > it. Michael Walle has confirmed that ignoring the error was intentional, > and we preserve that: > https://lore.kernel.org/linux-phy/[email protected]/ > > Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
