aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/sm_ftl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/sm_ftl.c')
-rw-r--r--drivers/mtd/sm_ftl.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index 4b8e89583f2a..cf49c22673b9 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -59,15 +59,12 @@ static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
59 struct attribute_group *attr_group; 59 struct attribute_group *attr_group;
60 struct attribute **attributes; 60 struct attribute **attributes;
61 struct sm_sysfs_attribute *vendor_attribute; 61 struct sm_sysfs_attribute *vendor_attribute;
62 char *vendor;
62 63
63 int vendor_len = strnlen(ftl->cis_buffer + SM_CIS_VENDOR_OFFSET, 64 vendor = kstrndup(ftl->cis_buffer + SM_CIS_VENDOR_OFFSET,
64 SM_SMALL_PAGE - SM_CIS_VENDOR_OFFSET); 65 SM_SMALL_PAGE - SM_CIS_VENDOR_OFFSET, GFP_KERNEL);
65
66 char *vendor = kmalloc(vendor_len, GFP_KERNEL);
67 if (!vendor) 66 if (!vendor)
68 goto error1; 67 goto error1;
69 memcpy(vendor, ftl->cis_buffer + SM_CIS_VENDOR_OFFSET, vendor_len);
70 vendor[vendor_len] = 0;
71 68
72 /* Initialize sysfs attributes */ 69 /* Initialize sysfs attributes */
73 vendor_attribute = 70 vendor_attribute =
@@ -78,7 +75,7 @@ static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
78 sysfs_attr_init(&vendor_attribute->dev_attr.attr); 75 sysfs_attr_init(&vendor_attribute->dev_attr.attr);
79 76
80 vendor_attribute->data = vendor; 77 vendor_attribute->data = vendor;
81 vendor_attribute->len = vendor_len; 78 vendor_attribute->len = strlen(vendor);
82 vendor_attribute->dev_attr.attr.name = "vendor"; 79 vendor_attribute->dev_attr.attr.name = "vendor";
83 vendor_attribute->dev_attr.attr.mode = S_IRUGO; 80 vendor_attribute->dev_attr.attr.mode = S_IRUGO;
84 vendor_attribute->dev_attr.show = sm_attr_show; 81 vendor_attribute->dev_attr.show = sm_attr_show;