From: Ally Heev Date: Wed, 5 Nov 2025 14:14:43 +0000 (+0530) Subject: scsi: scsi_debug: Fix uninitialized pointers with __free attr X-Git-Tag: v6.19-rc1~95^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3813d28b2b12dea8f44a6828b9c30b38208d3fc5;p=thirdparty%2Fkernel%2Flinux.git scsi: scsi_debug: Fix uninitialized pointers with __free attr Uninitialized pointers with '__free' attribute can cause undefined behaviour as the memory assigned(randomly) to the pointer is freed automatically when the pointer goes out of scope scsi doesn't have any bugs related to this as of now, but it is better to initialize and assign pointers with '__free' attr in one statement to ensure proper scope-based cleanup Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/ Signed-off-by: Ally Heev Link: https://patch.msgid.link/20251105-aheev-uninitialized-free-attr-scsi-v1-1-d28435a0a7ea@gmail.com Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 7291b7a7f1b08..92b2af803d87e 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2961,11 +2961,11 @@ static int resp_mode_sense(struct scsi_cmnd *scp, int target_dev_id; int target = scp->device->id; unsigned char *ap; - unsigned char *arr __free(kfree); unsigned char *cmd = scp->cmnd; bool dbd, llbaa, msense_6, is_disk, is_zbc, is_tape; - arr = kzalloc(SDEBUG_MAX_MSENSE_SZ, GFP_ATOMIC); + unsigned char *arr __free(kfree) = kzalloc(SDEBUG_MAX_MSENSE_SZ, GFP_ATOMIC); + if (!arr) return -ENOMEM; dbd = !!(cmd[1] & 0x8); /* disable block descriptors */