Skip to contentSkip to conversation

edac: edac_device_sysfs: reject poll_msec value 0

PATCH Superseded Jad Keskes 2 participants 3 messages Jul 8 – Jul 10 EDAC-core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jad Keskes

author
#0 lore raw

PATCH 1/2 edac: edac_device_sysfs: reject poll_msec value 0

The comment says it must be at least 1ms but there was never a check. Writing 0 sets the workqueue delay to 0 jiffies, which makes it spin.

---
 drivers/edac/edac_device_sysfs.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/edac_device_sysfs.c +4 -0
index da804ebe3626..3137cf6cf36b 100644
@@ -117,6 +117,10 @@ static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
 	ret = kstrtoul(data, 0, &value);
 	if (ret < 0)
 		return ret;
+
+	if (value < 1)
+		return -EINVAL;
+
 	edac_device_reset_delay_period(ctl_info, value);
 
 	return count;
Signature · 1 line
2.55.0
author
#1 lore raw

PATCH 2/2 edac: edac_device: don't re-arm workqueue during teardown

edac_device_del_device stops the workqueue then removes the sysfs attributes. But the sysfs store for poll_msec calls edac_device_reset_delay_period which unconditionally re-arms the workqueue. If someone writes to poll_msec in that window, the re-armed work runs after edac_dev is freed.

Check op_state instead. del_device already sets it to OP_OFFLINE before tearing down the workqueue, so reset_delay_period will see it and skip the mod_work call.

---
 drivers/edac/edac_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/edac_device.c +4 -0
index cf0d3c2dfc04..50ae7f1e5152 100644
@@ -354,6 +354,10 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
 	edac_dev->poll_msec = msec;
 	edac_dev->delay	    = msecs_to_jiffies(msec);
 
+	/* Don't re-arm the workqueue if the device is being torn down */
+	if (edac_dev->op_state == OP_OFFLINE)
+		return;
+
 	/* See comment in edac_device_workq_setup() above */
 	if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
 		edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
Signature · 1 line
2.55.0
maintainer
#2 lore raw
In reply to Jad Keskes
Quoted 1 line · Jad Keskes

Subject: Re: [PATCH 1/2] edac: edac_device_sysfs: reject poll_msec value 0

Do

$ git log -p drivers/edac/

to get an idea about the commit title and formatting the EDAC tree does. In this case:

EDAC/device_sysfs: Reject poll_msec value 0

Quoted 2 lines

The comment says it must be at least 1ms but there was never a check. Writing 0 sets the workqueue delay to 0 jiffies, which makes it spin.

You might run this through AI to get better/more informative formulations.

Some hints about a good commit message:

https://docs.kernel.org/process/submitting-patches.html

drivers/edac/edac_device_sysfs.c static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info · line 117

Quoted 11 lines
---
 drivers/edac/edac_device_sysfs.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/edac_device_sysfs.c +0 -0
index da804ebe3626..3137cf6cf36b 100644
@@ -117,6 +117,10 @@ static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
 	ret = kstrtoul(data, 0, &value);

If you do those patches ontop of your previous ones, it doesn't apply:

checking file drivers/edac/edac_device_sysfs.c
Hunk #1 FAILED at 117.
1 out of 1 hunk FAILED

But you need to do those fixes first and then the conversion to kstrtoul() because the fixes will go to stable while the kstrtoul() conversion is not stable material.

Which means, you'd need to add a Fixes: tag to those but that's fine if you can't find which patch causes this - I believe this has always been this way.

So, how about a new patchset with all that review feedback addressed, the fixes first, the conversion following, all nicely tested, if you don't know how use this here in a VM:

https://lore.kernel.org/all/[email protected]

Thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette