drivers/misc/mei/interrupt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Mar 2025 18:11:05 +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@users.sourceforge.net>
---
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 | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index b09b79fedaba..af5f01eefea4 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -136,7 +136,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
cb->ext_hdr = kzalloc(sizeof(*gsc_f2h), GFP_KERNEL);
if (!cb->ext_hdr) {
cb->status = -ENOMEM;
- goto discard;
+ goto move_tail;
}
break;
case MEI_EXT_HDR_NONE:
@@ -153,7 +153,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
if (!vtag_hdr && !gsc_f2h) {
cl_dbg(dev, cl, "no vtag or gsc found in extended header.\n");
cb->status = -EPROTO;
- goto discard;
+ goto move_tail;
}
}
@@ -163,7 +163,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
cl_err(dev, cl, "mismatched tag: %d != %d\n",
cb->vtag, vtag_hdr->vtag);
cb->status = -EPROTO;
- goto discard;
+ goto move_tail;
}
cb->vtag = vtag_hdr->vtag;
}
@@ -174,18 +174,18 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
if (!dev->hbm_f_gsc_supported) {
cl_err(dev, cl, "gsc extended header is not supported\n");
cb->status = -EPROTO;
- goto discard;
+ goto move_tail;
}
if (length) {
cl_err(dev, cl, "no data allowed in cb with gsc\n");
cb->status = -EPROTO;
- goto discard;
+ goto move_tail;
}
if (ext_hdr_len > sizeof(*gsc_f2h)) {
cl_err(dev, cl, "gsc extended header is too big %u\n", ext_hdr_len);
cb->status = -EPROTO;
- goto discard;
+ goto move_tail;
}
memcpy(cb->ext_hdr, gsc_f2h, ext_hdr_len);
}
@@ -193,7 +193,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
if (!mei_cl_is_connected(cl)) {
cl_dbg(dev, cl, "not connected\n");
cb->status = -ENODEV;
- goto discard;
+ goto move_tail;
}
if (mei_hdr->dma_ring)
@@ -205,14 +205,14 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
cl_err(dev, cl, "message is too big len %d idx %zu\n",
length, cb->buf_idx);
cb->status = -EMSGSIZE;
- goto discard;
+ goto move_tail;
}
if (cb->buf.size < buf_sz) {
cl_dbg(dev, cl, "message overflow. size %zu len %d idx %zu\n",
cb->buf.size, length, cb->buf_idx);
cb->status = -EMSGSIZE;
- goto discard;
+ goto move_tail;
}
if (mei_hdr->dma_ring) {
@@ -235,9 +235,9 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
return 0;
+move_tail:
+ list_move_tail(&cb->list, cmpl_list);
discard:
- if (cb)
- list_move_tail(&cb->list, cmpl_list);
mei_irq_discard_msg(dev, mei_hdr, length);
return 0;
}
--
2.48.1
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 4 Mar 2025 18:11:05 +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@users.sourceforge.net>
> ---
>
> 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 | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
> index b09b79fedaba..af5f01eefea4 100644
> --- a/drivers/misc/mei/interrupt.c
> +++ b/drivers/misc/mei/interrupt.c
> @@ -136,7 +136,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> cb->ext_hdr = kzalloc(sizeof(*gsc_f2h),
> GFP_KERNEL);
> if (!cb->ext_hdr) {
> cb->status = -ENOMEM;
> - goto discard;
> + goto move_tail;
> }
> break;
> case MEI_EXT_HDR_NONE:
> @@ -153,7 +153,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> if (!vtag_hdr && !gsc_f2h) {
> cl_dbg(dev, cl, "no vtag or gsc found in extended
> header.\n");
> cb->status = -EPROTO;
> - goto discard;
> + goto move_tail;
> }
> }
>
> @@ -163,7 +163,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> cl_err(dev, cl, "mismatched tag: %d != %d\n",
> cb->vtag, vtag_hdr->vtag);
> cb->status = -EPROTO;
> - goto discard;
> + goto move_tail;
> }
> cb->vtag = vtag_hdr->vtag;
> }
> @@ -174,18 +174,18 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> if (!dev->hbm_f_gsc_supported) {
> cl_err(dev, cl, "gsc extended header is not
> supported\n");
> cb->status = -EPROTO;
> - goto discard;
> + goto move_tail;
> }
>
> if (length) {
> cl_err(dev, cl, "no data allowed in cb with gsc\n");
> cb->status = -EPROTO;
> - goto discard;
> + goto move_tail;
> }
> if (ext_hdr_len > sizeof(*gsc_f2h)) {
> cl_err(dev, cl, "gsc extended header is too big %u\n",
> ext_hdr_len);
> cb->status = -EPROTO;
> - goto discard;
> + goto move_tail;
> }
> memcpy(cb->ext_hdr, gsc_f2h, ext_hdr_len);
> }
> @@ -193,7 +193,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> if (!mei_cl_is_connected(cl)) {
> cl_dbg(dev, cl, "not connected\n");
> cb->status = -ENODEV;
> - goto discard;
> + goto move_tail;
> }
>
> if (mei_hdr->dma_ring)
> @@ -205,14 +205,14 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
> cl_err(dev, cl, "message is too big len %d idx %zu\n",
> length, cb->buf_idx);
> cb->status = -EMSGSIZE;
> - goto discard;
> + goto move_tail;
> }
>
> if (cb->buf.size < buf_sz) {
> cl_dbg(dev, cl, "message overflow. size %zu len %d idx
> %zu\n",
> cb->buf.size, length, cb->buf_idx);
> cb->status = -EMSGSIZE;
> - goto discard;
> + goto move_tail;
> }
>
> if (mei_hdr->dma_ring) {
> @@ -235,9 +235,9 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
>
> return 0;
>
> +move_tail:
In general, why not, but the label naming is bad.
It hides the original intent to discard this message.
Let's rename existing label to discard_nocb: and leave a new one as discard:.
Also, the patch will be smaller in this way.
- -
Thanks,
Sasha
> + list_move_tail(&cb->list, cmpl_list);
> discard:
> - if (cb)
> - list_move_tail(&cb->list, cmpl_list);
> mei_irq_discard_msg(dev, mei_hdr, length);
> return 0;
> }
> --
> 2.48.1
>> 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. … >> +move_tail: > > In general, why not, but the label naming is bad. > It hides the original intent to discard this message. > Let's rename existing label to discard_nocb: and leave a new one as discard:. > Also, the patch will be smaller in this way. Do you expect a third patch version according to your naming preferences? Regards, Markus
> > > > In general, why not, but the label naming is bad. > > It hides the original intent to discard this message. > > Let's rename existing label to discard_nocb: and leave a new one as discard:. > > Also, the patch will be smaller in this way. > > Do you expect a third patch version according to your naming preferences? > > Regards, > Markus I prefer to, as the current patch reduces this code readability. - - Thanks, Sasha
On Wed, Mar 05, 2025 at 07:41:25AM +0000, Usyskin, Alexander wrote: > > > > > > In general, why not, but the label naming is bad. > > > It hides the original intent to discard this message. > > > Let's rename existing label to discard_nocb: and leave a new one as discard:. > > > Also, the patch will be smaller in this way. > > > > Do you expect a third patch version according to your naming preferences? > > > > Regards, > > Markus > > I prefer to, as the current patch reduces this code readability. > > - - > Thanks, > Sasha > > Hi, This is the semi-friendly patch-bot of Greg Kroah-Hartman. Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them. thanks, greg k-h's patch email bot
From: Markus Elfring <elfring@users.sourceforge.net>
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@users.sourceforge.net>
---
V3:
The label selection was adjusted according to the naming preferences
of Alexander Usyskin.
https://lore.kernel.org/cocci/CY5PR11MB6366D07A7F302780A87160E6EDCB2@CY5PR11MB6366.namprd11.prod.outlook.com/
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
© 2016 - 2026 Red Hat, Inc.