All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()
@ 2012-10-24  7:11 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-10-24  7:11 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, kernel-janitors

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f505402..f4222a4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()
@ 2012-10-24  7:11 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-10-24  7:11 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, kernel-janitors

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f505402..f4222a4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-24  7:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24  7:11 [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl() Dan Carpenter
2012-10-24  7:11 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.