All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()
Date: Wed, 24 Oct 2012 07:11:47 +0000	[thread overview]
Message-ID: <20121024071146.GA2536@elgon.mountain> (raw)

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;

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl()
Date: Wed, 24 Oct 2012 10:11:47 +0300	[thread overview]
Message-ID: <20121024071146.GA2536@elgon.mountain> (raw)

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;

             reply	other threads:[~2012-10-24  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  7:11 Dan Carpenter [this message]
2012-10-24  7:11 ` [patch] compat_ioctl: cleanup a type in do_i2c_rdwr_ioctl() Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121024071146.GA2536@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.