|
@@ -337,6 +337,7 @@ static ssize_t backing_dev_store(struct device *dev,
|
|
|
struct device_attribute *attr, const char *buf, size_t len)
|
|
|
{
|
|
|
char *file_name;
|
|
|
+ size_t sz;
|
|
|
struct file *backing_dev = NULL;
|
|
|
struct inode *inode;
|
|
|
struct address_space *mapping;
|
|
@@ -357,7 +358,11 @@ static ssize_t backing_dev_store(struct device *dev,
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- strlcpy(file_name, buf, len);
|
|
|
+ strlcpy(file_name, buf, PATH_MAX);
|
|
|
+ /* ignore trailing newline */
|
|
|
+ sz = strlen(file_name);
|
|
|
+ if (sz > 0 && file_name[sz - 1] == '\n')
|
|
|
+ file_name[sz - 1] = 0x00;
|
|
|
|
|
|
backing_dev = filp_open(file_name, O_RDWR|O_LARGEFILE, 0);
|
|
|
if (IS_ERR(backing_dev)) {
|