Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i3c: adi: Fix confusing cleanup.h syntax

Initializing automatic __free variables to NULL without need (e.g.
branches with different allocations), followed by actual allocation is
in contrary to explicit coding rules guiding cleanup.h:

"Given that the "__free(...) = NULL" pattern for variables defined at
the top of the function poses this potential interdependency problem the
recommendation is to always define and assign variables in one statement
and not group variable definitions at the top of the function when
__free() is used."

Code does not have a bug, but is less readable and uses discouraged
coding practice, so fix that by moving declaration to the place of
assignment.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251208020750.4727-4-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Krzysztof Kozlowski and committed by
Alexandre Belloni
136209e6 cc3b18f9

+4 -6
+4 -6
drivers/i3c/master/adi-i3c-master.c
··· 332 332 struct i3c_ccc_cmd *cmd) 333 333 { 334 334 struct adi_i3c_master *master = to_adi_i3c_master(m); 335 - struct adi_i3c_xfer *xfer __free(kfree) = NULL; 336 335 struct adi_i3c_cmd *ccmd; 337 336 338 - xfer = adi_i3c_master_alloc_xfer(master, 1); 337 + struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, 1); 339 338 if (!xfer) 340 339 return -ENOMEM; 341 340 ··· 370 371 { 371 372 struct i3c_master_controller *m = i3c_dev_get_master(dev); 372 373 struct adi_i3c_master *master = to_adi_i3c_master(m); 373 - struct adi_i3c_xfer *xfer __free(kfree) = NULL; 374 374 int i, ret; 375 375 376 376 if (!nxfers) 377 377 return 0; 378 378 379 - xfer = adi_i3c_master_alloc_xfer(master, nxfers); 379 + struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, nxfers); 380 380 if (!xfer) 381 381 return -ENOMEM; 382 382 ··· 775 777 { 776 778 struct i3c_master_controller *m = i2c_dev_get_master(dev); 777 779 struct adi_i3c_master *master = to_adi_i3c_master(m); 778 - struct adi_i3c_xfer *xfer __free(kfree) = NULL; 779 780 int i; 780 781 781 782 if (!nxfers) ··· 783 786 if (xfers[i].flags & I2C_M_TEN) 784 787 return -EOPNOTSUPP; 785 788 } 786 - xfer = adi_i3c_master_alloc_xfer(master, nxfers); 789 + 790 + struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, nxfers); 787 791 if (!xfer) 788 792 return -ENOMEM; 789 793