Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:17 -0000
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-12@freebsd.org
Subject:   svn commit: r345932 - stable/12/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201904051127.x35BRm4d008115@repo.freebsd.org>

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

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/12/sys/compat/linuxkpi/common/include/linux/sysfs.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h	Fri Apr  5 11:27:35 2019	(r345931)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h	Fri Apr  5 11:27:48 2019	(r345932)
@@ -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.x35BRm4d008115>