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

Subsystems: system control & power/management interface (scpi/scmi) message protocol drivers, the rest

STALE2130d

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

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

From: Qinglang Miao <hidden>
Date: 2020-11-09 09:10:15

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")
Signed-off-by: Qinglang Miao <redacted>
---
 drivers/firmware/arm_scmi/notify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index 2754f9d01636..3048e57d9731 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -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);
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] firmware: arm_scmi: fix missing destroy_workqueue() on error in scmi_notification_init

From: Cristian Marussi <cristian.marussi@arm.com>
Date: 2020-11-09 17:51:42

On Mon, Nov 09, 2020 at 05:15:17PM +0800, Qinglang Miao wrote:
quoted hunk
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")
Signed-off-by: Qinglang Miao <redacted>
---
 drivers/firmware/arm_scmi/notify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index 2754f9d01636..3048e57d9731 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -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

 	mutex_init(&ni->pending_mtx);
 	hash_init(ni->pending_events_handlers);
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] firmware: arm_scmi: fix missing destroy_workqueue() on error in scmi_notification_init

From: Qinglang Miao <hidden>
Date: 2020-11-10 01:23:23


在 2020/11/10 1:51, Cristian Marussi 写道:
On Mon, Nov 09, 2020 at 05:15:17PM +0800, Qinglang Miao wrote:
quoted
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")
Signed-off-by: Qinglang Miao <redacted>
---
  drivers/firmware/arm_scmi/notify.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index 2754f9d01636..3048e57d9731 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -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
It sounds convincible to me Cristian, thanks for your advice ;D

I will send a v2 patch on this one in no time.
quoted
  	mutex_init(&ni->pending_mtx);
  	hash_init(ni->pending_events_handlers);
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help