From: Feng Tang <feng.tang@intel.com>
To: Dan Carpenter <error27@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
Alan Cox <alan@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [patch] mfd: snprintf() returns largish values
Date: Fri, 13 Aug 2010 01:23:51 +0000 [thread overview]
Message-ID: <20100813092351.326d9982@feng-i7> (raw)
In-Reply-To: <20100812075009.GK645@bicker>
On Thu, 12 Aug 2010 15:50:09 +0800
Dan Carpenter <error27@gmail.com> wrote:
> snprintf() returns the number of bytes which would have been written
> so it can be larger than the size of the buffer. In this case it's
> fine, but people copy and paste this code so I've fixed it.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/drivers/serial/mfd.c b/drivers/serial/mfd.c
> index bc9af50..5aa25e5 100644
> --- a/drivers/serial/mfd.c
> +++ b/drivers/serial/mfd.c
> @@ -171,6 +171,9 @@ static ssize_t port_show_regs(struct file *file,
> char __user *user_buf, len += snprintf(buf + len, HSU_REGS_BUFSIZE -
> len, "DIV: \t\t0x%08x\n", serial_in(up, UART_DIV));
>
> + if (len > HSU_REGS_BUFSIZE)
> + len = HSU_REGS_BUFSIZE;
> +
> ret = simple_read_from_buffer(user_buf, count, ppos, buf,
> len); kfree(buf);
> return ret;
> @@ -218,6 +221,9 @@ static ssize_t dma_show_regs(struct file *file,
> char __user *user_buf, len += snprintf(buf + len, HSU_REGS_BUFSIZE -
> len, "D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR));
>
> + if (len > HSU_REGS_BUFSIZE)
> + len = HSU_REGS_BUFSIZE;
> +
> ret = simple_read_from_buffer(user_buf, count, ppos, buf,
> len); kfree(buf);
> return ret;
Hi Carpenter,
It looks ok to me, thanks,
- Feng
prev parent reply other threads:[~2010-08-13 1:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 7:50 [patch] mfd: snprintf() returns largish values Dan Carpenter
2010-08-13 1:23 ` Feng Tang [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=20100813092351.326d9982@feng-i7 \
--to=feng.tang@intel.com \
--cc=alan@linux.intel.com \
--cc=error27@gmail.com \
--cc=gregkh@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox