Skip to contentSkip to conversation

scsi: virtio_scsi: Modify the kmalloc allocation flag

PATCH In review Li zeming 2 participants 2 messages Feb 16, 2023

Subsystems (3)
lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 scsi: virtio_scsi: Modify the kmalloc allocation flag

The inq_result pointer must be allocated successfully; otherwise, subsequent function execution may crash.

---
 drivers/scsi/virtio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/virtio_scsi.c +1 -1
index d07d24c06b54..3252f4b42261 100644
@@ -336,7 +336,7 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
 	struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
 	int result, inquiry_len, inq_result_len = 256;
-	char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);
+	char *inq_result = kmalloc(inq_result_len, __GFP_NOFAIL);
 
 	shost_for_each_device(sdev, shost) {
 		inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
Signature · 1 line
2.18.2
#1 lore raw
Quoted 2 lines · Li zeming

The inq_result pointer must be allocated successfully; otherwise, subsequent function execution may crash.

The error needs to be handled. Or in fact this LLDD needs to stop breaking layering and issuing it's own INQUIRY commands.