lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Dec 2019 17:16:36 +0200
From:   Alexandru Ardelean <alexandru.ardelean@...log.com>
To:     <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC:     <jic23@...nel.org>,
        Michael Hennerich <michael.hennerich@...log.com>,
        Alexandru Ardelean <alexandru.ardelean@...log.com>
Subject: [PATCH] iio: core: print error message on debugfs register failure

From: Michael Hennerich <michael.hennerich@...log.com>

If there's a failure when registering a debugfs entry for a device, don't
silently ignore the failure. Instead, print an error message and an error
code signaling the failure.

Signed-off-by: Michael Hennerich <michael.hennerich@...log.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
---
 drivers/iio/industrialio-core.c | 34 +++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index dab67cb69fe6..662dabf8b08c 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -364,23 +364,45 @@ static const struct file_operations iio_debugfs_reg_fops = {
 static void iio_device_unregister_debugfs(struct iio_dev *indio_dev)
 {
 	debugfs_remove_recursive(indio_dev->debugfs_dentry);
+	indio_dev->debugfs_dentry = NULL;
 }
 
 static void iio_device_register_debugfs(struct iio_dev *indio_dev)
 {
+	struct dentry *d;
+	int ret;
+
 	if (indio_dev->info->debugfs_reg_access == NULL)
 		return;
 
 	if (!iio_debugfs_dentry)
 		return;
 
-	indio_dev->debugfs_dentry =
-		debugfs_create_dir(dev_name(&indio_dev->dev),
-				   iio_debugfs_dentry);
+	d = debugfs_create_dir(dev_name(&indio_dev->dev), iio_debugfs_dentry);
+	if (IS_ERR_OR_NULL(d))
+		goto error;
+
+	indio_dev->debugfs_dentry = d;
+
+	d = debugfs_create_file("direct_reg_access", 0644,
+				indio_dev->debugfs_dentry, indio_dev,
+				&iio_debugfs_reg_fops);
+
+	if (IS_ERR_OR_NULL(d))
+		goto error;
 
-	debugfs_create_file("direct_reg_access", 0644,
-			    indio_dev->debugfs_dentry, indio_dev,
-			    &iio_debugfs_reg_fops);
+	return;
+
+error:
+	if (IS_ERR(d))
+		ret = PTR_ERR(d);
+	else
+		ret = -EFAULT;
+
+	dev_err(indio_dev->dev.parent,
+		"Error when trying to register debugfs: %d\n", ret);
+
+	iio_device_unregister_debugfs(indio_dev);
 }
 #else
 static void iio_device_register_debugfs(struct iio_dev *indio_dev)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ