[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1176220293.5572.16.camel@dix>
Date: Tue, 10 Apr 2007 17:51:33 +0200
From: Martin Peschke <mp3@...ibm.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org
Subject: [Patch] statistics: small cleanup in debugfs write function
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@...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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists