Skip to contentSkip to conversation

firmware: arm_scmi: fix missing destroy_workqueue() on error in scmi_notification_init

PATCH In review Qinglang Miao 2 participants 3 messages Nov 9, 2020 – Nov 10, 2020 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: arm_scmi: fix missing destroy_workqueue() on error in scmi_notification_init

Add the missing destroy_workqueue() before return from scmi_notification_init in the error handling case when fails to do devm_kcalloc().

Fixes bd31b249692e ("firmware: arm_scmi: Add notification dispatch and delivery")
---
 drivers/firmware/arm_scmi/notify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/notify.c +3 -1
index 2754f9d01636..3048e57d9731 100644
@@ -1476,8 +1476,10 @@ int scmi_notification_init(struct scmi_handle *handle)
 
 	ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO,
 						sizeof(char *), GFP_KERNEL);
-	if (!ni->registered_protocols)
+	if (!ni->registered_protocols) {
+		destroy_workqueue(ni->notify_wq);
 		goto err;
+	}
 
 	mutex_init(&ni->pending_mtx);
 	hash_init(ni->pending_events_handlers);
Signature · 1 line
2.23.0
#1 lore raw
Quoted 15 lines · Qinglang Miao

Add the missing destroy_workqueue() before return from scmi_notification_init in the error handling case when fails to do devm_kcalloc().

Fixes bd31b249692e ("firmware: arm_scmi: Add notification dispatch and delivery")
---
 drivers/firmware/arm_scmi/notify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/notify.c +0 -0
index 2754f9d01636..3048e57d9731 100644

drivers/firmware/arm_scmi/notify.c int scmi_notification_init(struct scmi_handle *handle) · line 1483

Quoted 9 lines
drivers/firmware/arm_scmi/notify.c +3 -1
@@ -1476,8 +1476,10 @@ int scmi_notification_init(struct scmi_handle *handle)
 
 	ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO,
 						sizeof(char *), GFP_KERNEL);
-	if (!ni->registered_protocols)
+	if (!ni->registered_protocols) {
+		destroy_workqueue(ni->notify_wq);
 		goto err;
+	}
 

Good catch, looks good to me.

Even better you could move the above alloc_workqueue() block down here so that you can avoid all together the additional destroy_workqueue() on the above error path.

Thanks

Cristian

Quoted 10 lines
drivers/firmware/arm_scmi/notify.c +0 -0
 	mutex_init(&ni->pending_mtx);
 	hash_init(ni->pending_events_handlers);
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw
Quoted 28 lines · Cristian Marussi
Quoted 15 lines · Qinglang Miao

Add the missing destroy_workqueue() before return from scmi_notification_init in the error handling case when fails to do devm_kcalloc().

Fixes bd31b249692e ("firmware: arm_scmi: Add notification dispatch and delivery")
---
  drivers/firmware/arm_scmi/notify.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/notify.c +0 -0
index 2754f9d01636..3048e57d9731 100644

drivers/firmware/arm_scmi/notify.c int scmi_notification_init(struct scmi_handle *handle) · line 1483

Quoted 9 lines
drivers/firmware/arm_scmi/notify.c +3 -1
@@ -1476,8 +1476,10 @@ int scmi_notification_init(struct scmi_handle *handle)
 
  	ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO,
  						sizeof(char *), GFP_KERNEL);
-	if (!ni->registered_protocols)
+	if (!ni->registered_protocols) {
+		destroy_workqueue(ni->notify_wq);
  		goto err;
+	}
 

Good catch, looks good to me.

Quoted 7 lines

Even better you could move the above alloc_workqueue() block down here so that you can avoid all together the additional destroy_workqueue() on the above error path.

Thanks

Cristian

It sounds convincible to me Cristian, thanks for your advice ;D

I will send a v2 patch on this one in no time.

Quoted 14 lines
Quoted 12 lines
drivers/firmware/arm_scmi/notify.c +0 -0
  	mutex_init(&ni->pending_mtx);
  	hash_init(ni->pending_events_handlers);
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

.