Skip to contentSkip to conversation

staging: greybus: fix an error handling bug in gb_svc_hello()

PATCH In review Dan Carpenter 2 participants 2 messages Feb 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: fix an error handling bug in gb_svc_hello()

Cleanup if gb_svc_queue_deferred_request() fails.

Fixes ee2f2074fdb2 ("greybus: svc: reconfig APBridgeA-Switch link to handle required load")

---
From static analysis. Not tested.

 drivers/greybus/svc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/greybus/svc.c +7 -1
index ce7740ef449b..b19651048081 100644
@@ -866,8 +866,14 @@ static int gb_svc_hello(struct gb_operation *op)
 
 	gb_svc_debugfs_init(svc);
 
-	return gb_svc_queue_deferred_request(op);
+	ret = gb_svc_queue_deferred_request(op);
+	if (ret)
+		goto remove_debugfs;
+
+	return 0;
 
+remove_debugfs:
+	gb_svc_debugfs_exit(svc);
 err_unregister_device:
 	gb_svc_watchdog_destroy(svc);
 	device_del(&svc->dev);
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 6 lines · Dan Carpenter

Cleanup if gb_svc_queue_deferred_request() fails.

Fixes ee2f2074fdb2 ("greybus: svc: reconfig APBridgeA-Switch link to handle required load")

---
From static analysis. Not tested.

Look correct. Thanks, Dan.

This part of Greybus no longer lives in staging and the prefix should be

greybus: svc:

I'd also prefer to see all error labels use an err_ prefix consistently.

When looking at this code I found another bug so I'll fix up the above nits and send a series with both fixes as there will be a dependency.

Quoted 13 lines
 drivers/greybus/svc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/greybus/svc.c +1 -1
index ce7740ef449b..b19651048081 100644
@@ -866,8 +866,14 @@ static int gb_svc_hello(struct gb_operation *op)
 
 	gb_svc_debugfs_init(svc);
 
-	return gb_svc_queue_deferred_request(op);
+	ret = gb_svc_queue_deferred_request(op);

drivers/greybus/svc.c static int gb_svc_hello(struct gb_operation *op) · line 879

Quoted 10 lines
drivers/greybus/svc.c +6 -0
+	if (ret)
+		goto remove_debugfs;
+
+	return 0;
 
+remove_debugfs:
+	gb_svc_debugfs_exit(svc);
 err_unregister_device:
 	gb_svc_watchdog_destroy(svc);
 	device_del(&svc->dev);

Johan