Skip to contentSkip to conversation

drivers/scsi/sr_ioctl.c: check for failed allocation

PATCH New Nate Dailey 1 participant 1 message Apr 21, 2005 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/scsi/sr_ioctl.c: check for failed allocation

Hi,

I noticed a case in sr_ioctl.c's sr_get_mcn where a buffer is allocated, but the pointer isn't checked for null.

This patch against 2.6.12-rc2 adds a check.

Nate Dailey
Stratus Technologies

drivers/scsi/sr_ioctl.c renamed from drivers/scsi/sr_ioctl.c.orig +3 -0
@@ -281,6 +281,9 @@ int sr_get_mcn(struct cdrom_device_info 
 	char *buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
 	int result;
 
+	if (!buffer)
+		return -ENOMEM;
+
 	memset(&cgc, 0, sizeof(struct packet_command));
 	cgc.cmd[0] = GPCMD_READ_SUBCHANNEL;
 	cgc.cmd[2] = 0x40;	/* I do want the subchannel info */