aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Perthuis <g2p.code@gmail.com>2013-09-24 02:17:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-05 10:13:09 -0400
commitbb343115253500dcee63ea78d765e4c2f2a57fc4 (patch)
treebc0cf6166685c72cd36400c4cb71758f42d56b85
parent0a22f485eee6ae8da77c3e37c8856e025678cdb0 (diff)
bcache: Strip endline when writing the label through sysfs
commit aee6f1cfff3ce240eb4b43b41ca466b907acbd2e upstream. sysfs attributes with unusual characters have crappy failure modes in Squeeze (udev 164); later versions of udev are unaffected. This should make these characters more unusual. Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com> Signed-off-by: Kent Overstreet <kmo@daterainc.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/bcache/sysfs.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 4d9cca47e4c6..e9bd6c0cca5b 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -214,7 +214,13 @@ STORE(__cached_dev)
214 } 214 }
215 215
216 if (attr == &sysfs_label) { 216 if (attr == &sysfs_label) {
217 memcpy(dc->sb.label, buf, SB_LABEL_SIZE); 217 if (size > SB_LABEL_SIZE)
218 return -EINVAL;
219 memcpy(dc->sb.label, buf, size);
220 if (size < SB_LABEL_SIZE)
221 dc->sb.label[size] = '\0';
222 if (size && dc->sb.label[size - 1] == '\n')
223 dc->sb.label[size - 1] = '\0';
218 bch_write_bdev_super(dc, NULL); 224 bch_write_bdev_super(dc, NULL);
219 if (dc->disk.c) { 225 if (dc->disk.c) {
220 memcpy(dc->disk.c->uuids[dc->disk.id].label, 226 memcpy(dc->disk.c->uuids[dc->disk.id].label,