Skip to content

Commit 9465744

Browse files
krzkmartinkpetersen
authored andcommitted
scsi: ufs: qcom: 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> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20251208020807.5043-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 362432e commit 9465744

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/ufs/host/ufs-qcom.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,10 +1769,9 @@ static void ufs_qcom_dump_testbus(struct ufs_hba *hba)
17691769
{
17701770
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
17711771
int i, j, nminor = 0, testbus_len = 0;
1772-
u32 *testbus __free(kfree) = NULL;
17731772
char *prefix;
17741773

1775-
testbus = kmalloc_array(256, sizeof(u32), GFP_KERNEL);
1774+
u32 *testbus __free(kfree) = kmalloc_array(256, sizeof(u32), GFP_KERNEL);
17761775
if (!testbus)
17771776
return;
17781777

@@ -1794,13 +1793,12 @@ static void ufs_qcom_dump_testbus(struct ufs_hba *hba)
17941793
static int ufs_qcom_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
17951794
const char *prefix, void __iomem *base)
17961795
{
1797-
u32 *regs __free(kfree) = NULL;
17981796
size_t pos;
17991797

18001798
if (offset % 4 != 0 || len % 4 != 0)
18011799
return -EINVAL;
18021800

1803-
regs = kzalloc(len, GFP_ATOMIC);
1801+
u32 *regs __free(kfree) = kzalloc(len, GFP_ATOMIC);
18041802
if (!regs)
18051803
return -ENOMEM;
18061804

0 commit comments

Comments
 (0)