From: Emil Goode <emilgoode@gmail.com>
To: gregkh@linuxfoundation.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
Emil Goode <emilgoode@gmail.com>
Subject: [PATCH] drivers/tty: Use get_user instead of dereferencing user pointer
Date: Fri, 20 Apr 2012 15:52:34 +0000 [thread overview]
Message-ID: <1334937154-23037-1-git-send-email-emilgoode@gmail.com> (raw)
We should use the get_user macro instead of dereferencing user
pointers directly.
This patch fixes the following sparse warning:
drivers/tty/n_tty.c:1648:51: warning:
dereference of noderef expression
Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
I'm a newbie so please review carefully.
Not sure if I should add error handling for the get_user call here.
drivers/tty/n_tty.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 94b6eda..5ff63cc 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1630,6 +1630,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
int retval;
size_t n;
unsigned long flags;
+ unsigned char ch;
retval = 0;
spin_lock_irqsave(&tty->read_lock, flags);
@@ -1645,7 +1646,8 @@ static int copy_from_read_buf(struct tty_struct *tty,
tty->read_cnt -= n;
/* Turn single EOF into zero-length read */
if (L_EXTPROC(tty) && tty->icanon && n = 1) {
- if (!tty->read_cnt && (*b)[n-1] = EOF_CHAR(tty))
+ get_user(ch, b[n-1]);
+ if (!tty->read_cnt && ch = EOF_CHAR(tty))
n--;
}
spin_unlock_irqrestore(&tty->read_lock, flags);
--
1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Emil Goode <emilgoode@gmail.com>
To: gregkh@linuxfoundation.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
Emil Goode <emilgoode@gmail.com>
Subject: [PATCH] drivers/tty: Use get_user instead of dereferencing user pointer
Date: Fri, 20 Apr 2012 17:52:34 +0200 [thread overview]
Message-ID: <1334937154-23037-1-git-send-email-emilgoode@gmail.com> (raw)
We should use the get_user macro instead of dereferencing user
pointers directly.
This patch fixes the following sparse warning:
drivers/tty/n_tty.c:1648:51: warning:
dereference of noderef expression
Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
I'm a newbie so please review carefully.
Not sure if I should add error handling for the get_user call here.
drivers/tty/n_tty.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 94b6eda..5ff63cc 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1630,6 +1630,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
int retval;
size_t n;
unsigned long flags;
+ unsigned char ch;
retval = 0;
spin_lock_irqsave(&tty->read_lock, flags);
@@ -1645,7 +1646,8 @@ static int copy_from_read_buf(struct tty_struct *tty,
tty->read_cnt -= n;
/* Turn single EOF into zero-length read */
if (L_EXTPROC(tty) && tty->icanon && n == 1) {
- if (!tty->read_cnt && (*b)[n-1] == EOF_CHAR(tty))
+ get_user(ch, b[n-1]);
+ if (!tty->read_cnt && ch == EOF_CHAR(tty))
n--;
}
spin_unlock_irqrestore(&tty->read_lock, flags);
--
1.7.9.5
next reply other threads:[~2012-04-20 15:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 15:52 Emil Goode [this message]
2012-04-20 15:52 ` [PATCH] drivers/tty: Use get_user instead of dereferencing user pointer Emil Goode
2012-04-20 20:59 ` Alan Cox
2012-04-20 21:00 ` Alan Cox
2012-04-21 9:04 ` Jiri Slaby
2012-04-21 9:04 ` Jiri Slaby
2012-04-21 14:04 ` Howard Chu
2012-04-21 14:04 ` Howard Chu
2012-04-21 14:25 ` Howard Chu
2012-04-21 14:25 ` Howard Chu
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=1334937154-23037-1-git-send-email-emilgoode@gmail.com \
--to=emilgoode@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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.