Skip to contentSkip to conversation

misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

PATCH In review Dan Carpenter 3 participants 5 messages Feb 1, 2021

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

PATCH 1/1 misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

Unlock before returning on this error path.

Fixes 111d746bb476 ("misc: bcm-vk: add VK messaging support")
---
 drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +2 -1
index eec90494777d..fc972e43258a 100644
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
 				 * that is fatal.
 				 */
 				dev_crit(dev, "Kernel mem allocation failure.\n");
-				return -ENOMEM;
+				total = -ENOMEM;
+				goto idx_err;
 			}
 
 			/* flush rd pointer after a message is dequeued */
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 13 lines · Dan Carpenter

Unlock before returning on this error path.

Fixes 111d746bb476 ("misc: bcm-vk: add VK messaging support")
---
 drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +0 -0
index eec90494777d..fc972e43258a 100644

drivers/misc/bcm-vk/bcm_vk_msg.c s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk) · line 855

Quoted 8 lines
drivers/misc/bcm-vk/bcm_vk_msg.c +2 -1
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
 				 * that is fatal.
 				 */
 				dev_crit(dev, "Kernel mem allocation failure.\n");
-				return -ENOMEM;
+				total = -ENOMEM;
+				goto idx_err;
 			}
 

This is a pretty fatal case if we fail to allocate memory here.
Will let Desmond respond if we wanted to keep the mutex locked forever in this case or if we do want to return and keep mutex locked if it is fatal and there is no real recovery path.

Quoted 1 line
drivers/misc/bcm-vk/bcm_vk_msg.c +0 -0
 			/* flush rd pointer after a message is dequeued */
#2 lore raw

Yes, in this situation, it is fatal and we would turn off processing anyway. But, Dan's change seems more appropriate and proper practice (thxs for the patch).

Des

Quoted 31 lines · Scott Branden
Quoted 13 lines · Dan Carpenter

Unlock before returning on this error path.

Fixes 111d746bb476 ("misc: bcm-vk: add VK messaging support")
---
 drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +0 -0
index eec90494777d..fc972e43258a 100644

drivers/misc/bcm-vk/bcm_vk_msg.c s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk) · line 855

Quoted 8 lines
drivers/misc/bcm-vk/bcm_vk_msg.c +2 -1
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
                               * that is fatal.
                               */
                              dev_crit(dev, "Kernel mem allocation failure.\n");
-                             return -ENOMEM;
+                             total = -ENOMEM;
+                             goto idx_err;
                      }
 

This is a pretty fatal case if we fail to allocate memory here.
Will let Desmond respond if we wanted to keep the mutex locked forever in this case or if we do want to return and keep mutex locked if it is fatal and there is no real recovery path.

Quoted 1 line
drivers/misc/bcm-vk/bcm_vk_msg.c +0 -0
                      /* flush rd pointer after a message is dequeued */
Acked-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter
Quoted 26 lines · Dan Carpenter

Unlock before returning on this error path.

Fixes 111d746bb476 ("misc: bcm-vk: add VK messaging support")
---
 drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +2 -2
index eec90494777d..fc972e43258a 100644
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
                                 * that is fatal.
                                 */
                                dev_crit(dev, "Kernel mem allocation failure.\n");
-                               return -ENOMEM;
+                               total = -ENOMEM;
+                               goto idx_err;
                        }
 
                        /* flush rd pointer after a message is dequeued */
--

2.29.2

maintainer Acked-by
#4 lore raw

Great, looks good then.

Quoted 1 line · Desmond Yan
Quoted 27 lines · Dan Carpenter
Quoted 25 lines

Unlock before returning on this error path.

Fixes 111d746bb476 ("misc: bcm-vk: add VK messaging support")
---
 drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +2 -2
index eec90494777d..fc972e43258a 100644
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
                                 * that is fatal.
                                 */
                                dev_crit(dev, "Kernel mem allocation failure.\n");
-                               return -ENOMEM;
+                               total = -ENOMEM;
+                               goto idx_err;
                        }
 
                        /* flush rd pointer after a message is dequeued */
--

2.29.2