[PATCH] powerpc/powernv/dump: Handle multiple writes to ack attribute

Subsystems: linux for powerpc (32-bit and 64-bit), the rest · Maintainers: Madhavan Srinivasan, Linus Torvalds

STALE2198d LANDED

Status: Landed in mainline as 358ab796ce78 on 2020-10-19.

2 messages, 2 authors, 2020-10-20 · open the first message on its own page

[PATCH] powerpc/powernv/dump: Handle multiple writes to ack attribute

From: Vasant Hegde <hidden>
Date: 2020-10-17 16:45:58

Even though we use self removing sysfs helper, we still need
to make sure we do the final kobject delete conditionally.
sysfs_remove_file_self() will handle parallel calls to remove
the sysfs attribute file and returns true only in the caller
that removed the attribute file. The other parallel callers
are returned false. Do the final kobject delete checking
the return value of sysfs_remove_file_self().

Cc: Aneesh Kumar K.V <redacted>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Vasant Hegde <redacted>
---
 arch/powerpc/platforms/powernv/opal-dump.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
index 0e6693bacb7e..00c5a59d82d9 100644
--- a/arch/powerpc/platforms/powernv/opal-dump.c
+++ b/arch/powerpc/platforms/powernv/opal-dump.c
@@ -88,9 +88,14 @@ static ssize_t dump_ack_store(struct dump_obj *dump_obj,
 			      const char *buf,
 			      size_t count)
 {
-	dump_send_ack(dump_obj->id);
-	sysfs_remove_file_self(&dump_obj->kobj, &attr->attr);
-	kobject_put(&dump_obj->kobj);
+	/*
+	 * Try to self remove this attribute. If we are successful,
+	 * delete the kobject itself.
+	 */
+	if (sysfs_remove_file_self(&dump_obj->kobj, &attr->attr)) {
+		dump_send_ack(dump_obj->id);
+		kobject_put(&dump_obj->kobj);
+	}
 	return count;
 }
 
-- 
2.26.2

Re: [PATCH] powerpc/powernv/dump: Handle multiple writes to ack attribute

From: Michael Ellerman <hidden>
Date: 2020-10-20 12:34:02

On Sat, 17 Oct 2020 22:12:36 +0530, Vasant Hegde wrote:
Even though we use self removing sysfs helper, we still need
to make sure we do the final kobject delete conditionally.
sysfs_remove_file_self() will handle parallel calls to remove
the sysfs attribute file and returns true only in the caller
that removed the attribute file. The other parallel callers
are returned false. Do the final kobject delete checking
the return value of sysfs_remove_file_self().
Applied to powerpc/fixes.

[1/1] powerpc/powernv/dump: Handle multiple writes to ack attribute
      https://git.kernel.org/powerpc/c/358ab796ce78ba271a6ff82834183ffb2cb68c4c

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help