Skip to contentSkip to conversation

pmcraid: redundant check in pmcraid_check_ioctl_buffer()?

PATCH In review Roel Kluin 2 participants 2 messages Oct 21, 2009 – Oct 22, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 pmcraid: redundant check in pmcraid_check_ioctl_buffer()?

struct pmcraid_ioctl_header member buffer_length is unsigned, so this check appears redundant.

---
Or should we replace it by a check like
if (hdr->buffer_length > MAX) ... ?

drivers/scsi/pmcraid.c +0 -6
index f7c70e2..e448776 100644
@@ -3731,12 +3731,6 @@ static int pmcraid_check_ioctl_buffer(
 		return -EINVAL;
 	}
 
-	/* buffer length can't be negetive */
-	if (hdr->buffer_length < 0) {
-		pmcraid_err("ioctl: invalid buffer length specified\n");
-		return -EINVAL;
-	}
-
 	/* check for appropriate buffer access */
 	if ((_IOC_DIR(cmd) & _IOC_READ) == _IOC_READ)
 		access = VERIFY_WRITE;
#1 lore raw

I agree this check is not necessary.

Quoted 26 lines · Roel Kluin

struct pmcraid_ioctl_header member buffer_length is unsigned, so this check appears redundant.

---
Or should we replace it by a check like
if (hdr->buffer_length > MAX) ... ?

drivers/scsi/pmcraid.c +0 -6
index f7c70e2..e448776 100644
@@ -3731,12 +3731,6 @@ static int pmcraid_check_ioctl_buffer(
 		return -EINVAL;
 	}
 
-	/* buffer length can't be negetive */
-	if (hdr->buffer_length < 0) {
-		pmcraid_err("ioctl: invalid buffer length specified\n");
-		return -EINVAL;
-	}
-
 	/* check for appropriate buffer access */
 	if ((_IOC_DIR(cmd) & _IOC_READ) == _IOC_READ)
 		access = VERIFY_WRITE;