Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Apr 2019 11:27:35 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r345931 - stable/11/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201904051127.x35BRZbO008062@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Apr  5 11:27:35 2019
New Revision: 345931
URL: https://svnweb.freebsd.org/changeset/base/345931

Log:
  MFC r345105:
  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>
  Sponsored by:		Limelight Networks
  Sponsored by:		Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h	Fri Apr  5 11:26:33 2019	(r345930)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h	Fri Apr  5 11:27:35 2019	(r345931)
@@ -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?201904051127.x35BRZbO008062>