From: Martin Peschke <mp3@de.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [Patch] statistics: small cleanup in debugfs write function
Date: Tue, 10 Apr 2007 17:51:33 +0200 [thread overview]
Message-ID: <1176220293.5572.16.camel@dix> (raw)
Code looks more sane with this little cleanup, although both memcpy()
and kfree() are supposed to cope with NULL pointer or zero length
respectively.
(Patch cleans up
statistics-infrastructure-simplify-statistics-debugfs-write-function.patch)
Patch is against 2.6.21-rc6-mm1.
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
---
statistic.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Index: linux/lib/statistic.c
===================================================================
--- linux.orig/lib/statistic.c
+++ linux/lib/statistic.c
@@ -631,11 +631,13 @@ static ssize_t statistic_write_def(struc
if (!larger)
return -ENOMEM;
larger[*offset + len] = '\0';
- memcpy(larger, seq_priv->w_buf, *offset);
+ if (seq_priv->w_buf) {
+ memcpy(larger, seq_priv->w_buf, *offset);
+ kfree(seq_priv->w_buf);
+ }
if (copy_from_user(larger + *offset, buf, len))
return -EFAULT;
*offset += len;
- kfree(seq_priv->w_buf);
seq_priv->w_buf = larger;
seq_priv->w_offset = *offset;
return len;
reply other threads:[~2007-04-10 15:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1176220293.5572.16.camel@dix \
--to=mp3@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@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.