Skip to contentSkip to conversation

compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()

PATCH New Dan Carpenter 1 participant 1 message Oct 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()

We check that:

if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
return -EINVAL;

Since "nmsgs" is signed, it means the check can underflow. It's harmless, but messy.

fs/compat_ioctl.c +2 -1
index f505402..f4222a4 100644
@@ -680,7 +680,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
 	struct i2c_msg			__user *tmsgs;
 	struct i2c_msg32		__user *umsgs;
 	compat_caddr_t			datap;
-	int				nmsgs, i;
+	unsigned int			nmsgs;
+	int				i;
 
 	if (get_user(nmsgs, &udata->nmsgs))
 		return -EFAULT;