Skip to contentSkip to conversation

megaraid:Fix possible NULL pointer deference in mraid_mm_ioctl

PATCH Sumit Saxena 1 participant 1 message Jan 8, 2016 1 message not in the archive SCSI

lore
Share & tools
lore

Sumit Saxena

author Acked-by
#1 lore raw
In reply to a message not in the archive
Quoted 11 lines

-----Original Message-----
From: Nicholas Krause [mailto:[email protected]]
Sent: Wednesday, January 06, 2016 1:03 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] megaraid:Fix possible NULL pointer deference in mraid_mm_ioctl

Quoted 1 line

This adds the needed check after the call to the function

mraid_mm_alloc_kioc

Quoted 1 line

in order to make sure that this function has not returned NULL and

therefore

Quoted 3 lines

makes sure we do not deference a NULL pointer if one is returned by mraid_mm_alloc_kioc.
Further more add needed comments explaining that this function call can

return

Quoted 1 line

NULL if the list head is empty for the pointer passed in order to allow

furture

drivers/scsi/megaraid/megaraid_mm.c mraid_mm_ioctl(struct file *filep, unsigned int

Quoted 13 lines

users to understand this required pointer check.

---
 drivers/scsi/megaraid/megaraid_mm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/megaraid/megaraid_mm.c +0 -0
index a706927..215ddbc 100644
@@ -179,8 +179,12 @@ mraid_mm_ioctl(struct file *filep, unsigned int

cmd,

Quoted 12 lines
drivers/scsi/megaraid/megaraid_mm.c +4 -0
 unsigned long arg)
 
 	/*
 	 * The following call will block till a kioc is available
+	 * or return NULL if the list head is empty for the pointer
+	 * of type mraid_mmapt passed to mraid_mm_alloc_kioc
 	 */
 	kioc = mraid_mm_alloc_kioc(adp);
+	if (!kioc)
+		return -ENXIO;
 
 	/*
Quoted 1 line

* User sent the old mimd_t ioctl packet. Convert it to uioc_t.

Quoted 2 lines

--
2.5.0