goto out_dput;
}
- error = -ENOMEM;
- attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
- if (!attr_name)
- goto out_kfree_ops;
-
error = 0;
for (i = 0; i < am_hreq.opcount; i++) {
if ((ops[i].am_flags & ATTR_ROOT) &&
}
ops[i].am_flags &= ~ATTR_KERNEL_FLAGS;
- ops[i].am_error = strncpy_from_user((char *)attr_name,
- ops[i].am_attrname, MAXNAMELEN);
- if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
- error = -ERANGE;
- if (ops[i].am_error < 0)
+ attr_name = strndup_user(ops[i].am_attrname, MAXNAMELEN);
+ if (IS_ERR(attr_name)) {
+ ops[i].am_error = PTR_ERR(attr_name);
break;
+ }
switch (ops[i].am_opcode) {
case ATTR_OP_GET:
default:
ops[i].am_error = -EINVAL;
}
+ kfree(attr_name);
}
if (copy_to_user(am_hreq.ops, ops, size))
error = -EFAULT;
- kfree(attr_name);
- out_kfree_ops:
kfree(ops);
out_dput:
dput(dentry);
goto out_dput;
}
- error = -ENOMEM;
- attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
- if (!attr_name)
- goto out_kfree_ops;
-
error = 0;
for (i = 0; i < am_hreq.opcount; i++) {
if ((ops[i].am_flags & ATTR_ROOT) &&
}
ops[i].am_flags &= ~ATTR_KERNEL_FLAGS;
- ops[i].am_error = strncpy_from_user((char *)attr_name,
- compat_ptr(ops[i].am_attrname),
+ attr_name = strndup_user(compat_ptr(ops[i].am_attrname),
MAXNAMELEN);
- if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
- error = -ERANGE;
- if (ops[i].am_error < 0)
+ if (IS_ERR(attr_name)) {
+ ops[i].am_error = PTR_ERR(attr_name);
break;
+ }
switch (ops[i].am_opcode) {
case ATTR_OP_GET:
default:
ops[i].am_error = -EINVAL;
}
+ kfree(attr_name);
}
if (copy_to_user(compat_ptr(am_hreq.ops), ops, size))
error = -EFAULT;
- kfree(attr_name);
- out_kfree_ops:
kfree(ops);
out_dput:
dput(dentry);