Honor SYSCTL function return values when creating sysfs nodes in the LinuxKPI.

Return proper error code upon failure.

Submitted by:		Johannes Lundberg <johalun0@gmail.com>
MFC after:		1 week
Sponsored by:		Limelight Networks
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2019-03-13 19:21:19 +00:00
parent 925245aaa9
commit 0ac26c0e30

View File

@ -132,10 +132,14 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
static inline int
sysfs_create_file(struct kobject *kobj, const struct attribute *attr)
{
struct sysctl_oid *oid;
SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO,
oid = SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO,
attr->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, kobj,
(uintptr_t)attr, sysctl_handle_attr, "A", "");
if (!oid) {
return (-ENOMEM);
}
return (0);
}
@ -176,9 +180,14 @@ sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp)
static inline int
sysfs_create_dir(struct kobject *kobj)
{
struct sysctl_oid *oid;
kobj->oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->parent->oidp),
oid = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->parent->oidp),
OID_AUTO, kobj->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, kobj->name);
if (!oid) {
return (-ENOMEM);
}
kobj->oidp = oid;
return (0);
}