From: Simon Horman <horms@verge.net.au>
To: Vasiliy Kulikov <segooon@gmail.com>
Cc: kernel-janitors@vger.kernel.org,
Greg Kroah-Hartman <gregkh@suse.de>,
H Hartley Sweeten <hsweeten@visionengravers.com>,
Joe Eloff <kagen101@gmail.com>,
Randy Dunlap <randy.dunlap@oracle.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/9 v3] staging: dt3155: check put_user() return value
Date: Mon, 2 Aug 2010 22:51:35 +0900 [thread overview]
Message-ID: <20100802135135.GJ5814@verge.net.au> (raw)
In-Reply-To: <20100802125638.GA6412@albatros>
On Mon, Aug 02, 2010 at 04:56:38PM +0400, Vasiliy Kulikov wrote:
> put_user() returns code was not checked for errors. To simplify the code
> fill local struct dt3155_read with data and copy it with single
> copy_to_user() call.
>
> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Looks good to me.
Reviewed-by: Simon Horman <horms@verge.net.au>
> ---
> drivers/staging/dt3155/dt3155_drv.c | 13 ++++++-------
> 1 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
> index 7316996..6031837 100644
> --- a/drivers/staging/dt3155/dt3155_drv.c
> +++ b/drivers/staging/dt3155/dt3155_drv.c
> @@ -745,6 +745,7 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
> struct dt3155_status *dts = &dt3155_status[minor];
> struct dt3155_fbuffer *fb = &dts->fbuffer;
> struct frame_info *frame_info;
> + struct dt3155_read dt_read;
>
> /* TODO: this should check the error flag and */
> /* return an error on hardware failures */
> @@ -797,14 +798,12 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
>
> /* make this an offset */
> offset = frame_info->addr - dts->mem_addr;
> + dt_read.offset = offset;
> + dt_read.frame_seq = fb->frame_count;
> + dt_read.state = dts->state;
> + memcpy(&dt_read.frame_info, frame_info, sizeof(struct frame_info));
>
> - put_user(offset, (unsigned int __user *)buf);
> - buf += sizeof(u32);
> - put_user(fb->frame_count, (unsigned int __user *)buf);
> - buf += sizeof(u32);
> - put_user(dts->state, (unsigned int __user *)buf);
> - buf += sizeof(u32);
> - if (copy_to_user(buf, frame_info, sizeof(*frame_info)))
> + if (copy_to_user(buf, &dt_read, sizeof(struct dt3155_read)))
> return -EFAULT;
>
> return sizeof(struct dt3155_read);
> --
> 1.7.0.4
prev parent reply other threads:[~2010-08-02 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-02 8:31 [PATCH 1/9 v2] staging: dt3155: check put_user() return value Kulikov Vasiliy
2010-08-02 12:41 ` Simon Horman
2010-08-02 12:56 ` [PATCH 1/9 v3] " Vasiliy Kulikov
2010-08-02 13:51 ` Simon Horman [this message]
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=20100802135135.GJ5814@verge.net.au \
--to=horms@verge.net.au \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=hsweeten@visionengravers.com \
--cc=kagen101@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@oracle.com \
--cc=segooon@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox