]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Jan 2022 13:00:27 +0000 (14:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Jan 2022 13:00:27 +0000 (14:00 +0100)
added patches:
pm-wakeup-simplify-the-output-logic-of-pm_show_wakelocks.patch

queue-4.4/pm-wakeup-simplify-the-output-logic-of-pm_show_wakelocks.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/pm-wakeup-simplify-the-output-logic-of-pm_show_wakelocks.patch b/queue-4.4/pm-wakeup-simplify-the-output-logic-of-pm_show_wakelocks.patch
new file mode 100644 (file)
index 0000000..73e6339
--- /dev/null
@@ -0,0 +1,51 @@
+From c9d967b2ce40d71e968eb839f36c936b8a9cf1ea Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Thu, 13 Jan 2022 19:44:20 +0100
+Subject: PM: wakeup: simplify the output logic of pm_show_wakelocks()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+commit c9d967b2ce40d71e968eb839f36c936b8a9cf1ea upstream.
+
+The buffer handling in pm_show_wakelocks() is tricky, and hopefully
+correct.  Ensure it really is correct by using sysfs_emit_at() which
+handles all of the tricky string handling logic in a PAGE_SIZE buffer
+for us automatically as this is a sysfs file being read from.
+
+Reviewed-by: Lee Jones <lee.jones@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/power/wakelock.c |   12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
+
+--- a/kernel/power/wakelock.c
++++ b/kernel/power/wakelock.c
+@@ -38,23 +38,19 @@ ssize_t pm_show_wakelocks(char *buf, boo
+ {
+       struct rb_node *node;
+       struct wakelock *wl;
+-      char *str = buf;
+-      char *end = buf + PAGE_SIZE;
++      int len = 0;
+       mutex_lock(&wakelocks_lock);
+       for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) {
+               wl = rb_entry(node, struct wakelock, node);
+               if (wl->ws.active == show_active)
+-                      str += scnprintf(str, end - str, "%s ", wl->name);
++                      len += sysfs_emit_at(buf, len, "%s ", wl->name);
+       }
+-      if (str > buf)
+-              str--;
+-
+-      str += scnprintf(str, end - str, "\n");
++      len += sysfs_emit_at(buf, len, "\n");
+       mutex_unlock(&wakelocks_lock);
+-      return (str - buf);
++      return len;
+ }
+ #if CONFIG_PM_WAKELOCKS_LIMIT > 0
index 9effcb61160ec40874e5d3f2494e9605387464ff..e4d955eecc2995effb84a7e139b94c64374f6433 100644 (file)
@@ -4,3 +4,4 @@ s390-hypfs-include-z-vm-guests-with-access-control-group-set.patch
 scsi-zfcp-fix-failed-recovery-on-gone-remote-port-with-non-npiv-fcp-devices.patch
 udf-restore-i_lenalloc-when-inode-expansion-fails.patch
 udf-fix-null-ptr-deref-when-converting-from-inline-format.patch
+pm-wakeup-simplify-the-output-logic-of-pm_show_wakelocks.patch