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

i3c: master: 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.

Not that other existing usage of __free() in this context is a corret
exception initialized to NULL, because the actual allocation is branched
in if().

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

authored by

Krzysztof Kozlowski and committed by
Alexandre Belloni
cc3b18f9 41b80d43

+1 -2
+1 -2
drivers/i3c/master.c
··· 1742 1742 struct i3c_dma *i3c_master_dma_map_single(struct device *dev, void *buf, 1743 1743 size_t len, bool force_bounce, enum dma_data_direction dir) 1744 1744 { 1745 - struct i3c_dma *dma_xfer __free(kfree) = NULL; 1746 1745 void *bounce __free(kfree) = NULL; 1747 1746 void *dma_buf = buf; 1748 1747 1749 - dma_xfer = kzalloc(sizeof(*dma_xfer), GFP_KERNEL); 1748 + struct i3c_dma *dma_xfer __free(kfree) = kzalloc(sizeof(*dma_xfer), GFP_KERNEL); 1750 1749 if (!dma_xfer) 1751 1750 return NULL; 1752 1751