Message ID | 20201122061719.7voMbHRfP%akpm@linux-foundation.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/8] mm/madvise: fix memory leak from process_madvise | expand |
--- a/fs/libfs.c~libfs-fix-error-cast-of-negative-value-in-simple_attr_write +++ a/fs/libfs.c @@ -959,7 +959,7 @@ ssize_t simple_attr_write(struct file *f size_t len, loff_t *ppos) { struct simple_attr *attr; - u64 val; + unsigned long long val; size_t size; ssize_t ret; @@ -977,7 +977,9 @@ ssize_t simple_attr_write(struct file *f goto out; attr->set_buf[size] = '\0'; - val = simple_strtoll(attr->set_buf, NULL, 0); + ret = kstrtoull(attr->set_buf, 0, &val); + if (ret) + goto out; ret = attr->set(attr->data, val); if (ret == 0) ret = len; /* on success, claim we got the whole input */