[PATCH v3] mei: Improve exception handling in mei_cl_irq_read_msg()
From: Markus Elfring
Date: Mon Mar 24 2025 - 08:31:10 EST
From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Mar 2025 13:05:12 +0100
The label “discard” was used to jump to another pointer check despite of
the detail in the implementation of the function “mei_cl_irq_read_msg”
that it was determined already that a corresponding variable contained
a null pointer.
* Thus use an additional label instead.
* Delete a redundant check.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
V3:
The label selection was adjusted according to the naming preferences
of Alexander Usyskin.
https://lore.kernel.org/cocci/CY5PR11MB6366D07A7F302780A87160E6EDCB2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
V2:
* The summary phrase was adjusted a bit.
* The Fixes tags were omitted.
* The change suggestion was rebased on source files of
the software “Linux next-20250228”.
drivers/misc/mei/interrupt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index b09b79fedaba..78a01b402ea4 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -116,11 +116,11 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
if (!cb) {
if (!mei_cl_is_fixed_address(cl)) {
cl_err(dev, cl, "pending read cb not found\n");
- goto discard;
+ goto discard_nocb;
}
cb = mei_cl_alloc_cb(cl, mei_cl_mtu(cl), MEI_FOP_READ, cl->fp);
if (!cb)
- goto discard;
+ goto discard_nocb;
list_add_tail(&cb->list, &cl->rd_pending);
}
@@ -236,8 +236,8 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
return 0;
discard:
- if (cb)
- list_move_tail(&cb->list, cmpl_list);
+ list_move_tail(&cb->list, cmpl_list);
+discard_nocb:
mei_irq_discard_msg(dev, mei_hdr, length);
return 0;
}
--
2.49.0