Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2019 19:21:19 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345105 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201903131921.x2DJLJ0l003817@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed Mar 13 19:21:19 2019
New Revision: 345105
URL: https://svnweb.freebsd.org/changeset/base/345105

Log:
  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

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sysfs.h

Modified: head/sys/compat/linuxkpi/common/include/linux/sysfs.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/sysfs.h	Wed Mar 13 19:17:52 2019	(r345104)
+++ head/sys/compat/linuxkpi/common/include/linux/sysfs.h	Wed Mar 13 19:21:19 2019	(r345105)
@@ -132,10 +132,14 @@ out:
 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 
 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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903131921.x2DJLJ0l003817>