aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/bcache/sysfs.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-06 14:31:06 +0100
committerMark Brown <broonie@linaro.org>2013-10-06 14:31:06 +0100
commit626c75a01521adc3a71b43d49d4db3d956c41b9f (patch)
treeccd5afb442f5c1763e051b6f4359bde25e1bb373 /drivers/md/bcache/sysfs.c
parent7d89516d246691c9a82e75563294df01b768f1d6 (diff)
parenta3dfd8c06351968f2ec42feb1ae8dfab8b481225 (diff)
Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-android
Diffstat (limited to 'drivers/md/bcache/sysfs.c')
-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 4d9cca47e4c..e9bd6c0cca5 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -214,7 +214,13 @@ STORE(__cached_dev)
}
if (attr == &sysfs_label) {
- memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
+ if (size > SB_LABEL_SIZE)
+ return -EINVAL;
+ memcpy(dc->sb.label, buf, size);
+ if (size < SB_LABEL_SIZE)
+ dc->sb.label[size] = '\0';
+ if (size && dc->sb.label[size - 1] == '\n')
+ dc->sb.label[size - 1] = '\0';
bch_write_bdev_super(dc, NULL);
if (dc->disk.c) {
memcpy(dc->disk.c->uuids[dc->disk.id].label,