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:	Fri, 25 Jun 2010 17:55:11 +0900
From:	Magnus Damm <magnus.damm@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Greg Kroah-Hartman <gregkh@...e.de>,
	Randy Dunlap <rdunlap@...otime.net>, linux-doc@...r.kernel.org,
	Johannes Berg <johannes.berg@...el.com>,
	Dmitry Torokhov <dtor@...l.ru>,
	Marcel Holtmann <marcel@...tmann.org>,
	Magnus Damm <magnus.damm@...il.com>,
	Ming Lei <tom.leiming@...il.com>
Subject: [PATCH] firmware: Update hotplug script, remove sysfs files

From: Magnus Damm <damm@...nsource.se>

Update the in-kernel hotplug example script to work
properly with recent kernels. Without this fix the
script may load the firmware twice - both at "add"
and "remove" time.

The second load only triggers in the case when multiple
firmware images are used. A good example is the b43
driver which does not work properly without this fix.

While at it, make sure sysfs files are removed.

Signed-off-by: Magnus Damm <damm@...nsource.se>
---

 Documentation/firmware_class/hotplug-script |   17 +++++++++--------
 drivers/base/firmware_class.c               |    6 +++++-
 2 files changed, 14 insertions(+), 9 deletions(-)

--- 0001/Documentation/firmware_class/hotplug-script
+++ work/Documentation/firmware_class/hotplug-script	2010-06-25 14:46:17.000000000 +0900
@@ -6,11 +6,12 @@
 
 HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/
 
-echo 1 > /sys/$DEVPATH/loading
-cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
-echo 0 > /sys/$DEVPATH/loading
-
-# To cancel the load in case of error:
-#
-#	echo -1 > /sys/$DEVPATH/loading
-#
+if [ "$SUBSYSTEM" == "firmware" -a "$ACTION" == "add" ]; then
+  if [ -f $HOTPLUG_FW_DIR/$FIRMWARE ]; then
+    echo 1 > /sys/$DEVPATH/loading
+    cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
+    echo 0 > /sys/$DEVPATH/loading
+  else
+    echo -1 > /sys/$DEVPATH/loading
+  fi
+fi
--- 0001/drivers/base/firmware_class.c
+++ work/drivers/base/firmware_class.c	2010-06-25 14:48:53.000000000 +0900
@@ -508,7 +508,7 @@ static int fw_setup_device(struct firmwa
 	retval = device_create_file(f_dev, &dev_attr_loading);
 	if (retval) {
 		dev_err(device, "%s: device_create_file failed\n", __func__);
-		goto error_unreg;
+		goto error_unreg2;
 	}
 
 	if (uevent)
@@ -516,6 +516,8 @@ static int fw_setup_device(struct firmwa
 	*dev_p = f_dev;
 	goto out;
 
+error_unreg2:
+	sysfs_remove_bin_file(&f_dev->kobj, &fw_priv->attr_data);
 error_unreg:
 	device_unregister(f_dev);
 out:
@@ -578,6 +580,8 @@ _request_firmware(const struct firmware 
 	}
 	fw_priv->fw = NULL;
 	mutex_unlock(&fw_lock);
+	sysfs_remove_bin_file(&f_dev->kobj, &fw_priv->attr_data);
+	device_remove_file(f_dev, &dev_attr_loading);
 	device_unregister(f_dev);
 	goto out;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ