diff options
Diffstat (limited to 'drivers/md/bcache/sysfs.c')
-rw-r--r-- | drivers/md/bcache/sysfs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 4fe6ab2fbe2e..924dcfdae111 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c | |||
@@ -223,8 +223,13 @@ STORE(__cached_dev) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | if (attr == &sysfs_label) { | 225 | if (attr == &sysfs_label) { |
226 | /* note: endlines are preserved */ | 226 | if (size > SB_LABEL_SIZE) |
227 | memcpy(dc->sb.label, buf, SB_LABEL_SIZE); | 227 | return -EINVAL; |
228 | memcpy(dc->sb.label, buf, size); | ||
229 | if (size < SB_LABEL_SIZE) | ||
230 | dc->sb.label[size] = '\0'; | ||
231 | if (size && dc->sb.label[size - 1] == '\n') | ||
232 | dc->sb.label[size - 1] = '\0'; | ||
228 | bch_write_bdev_super(dc, NULL); | 233 | bch_write_bdev_super(dc, NULL); |
229 | if (dc->disk.c) { | 234 | if (dc->disk.c) { |
230 | memcpy(dc->disk.c->uuids[dc->disk.id].label, | 235 | memcpy(dc->disk.c->uuids[dc->disk.id].label, |