* [PATCH] wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache()
@ 2025-10-23 13:04 Rakuram Eswaran
2025-10-23 13:15 ` Lorenzo Bianconi
0 siblings, 1 reply; 3+ messages in thread
From: Rakuram Eswaran @ 2025-10-23 13:04 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, Rex Lu
Cc: linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek,
david.hunter.linux, khalid, skhan, linux-kernel-mentees,
kernel test robot, Dan Carpenter, Rakuram Eswaran
Smatch reported a warning that the NULL check on `p` in
`mt7996_msdu_page_get_from_cache()` is redundant:
drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1651
mt7996_msdu_page_get_from_cache() warn: can 'p' even be NULL?
The function first checks `list_empty(&dev->wed_rro.page_cache)` before
calling `list_first_entry()`. When the list is not empty,
`list_first_entry()` always returns a valid pointer and can never be NULL.
Hence, the `if (p)` condition is unnecessary. Removing it cleans up the
code.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202510100155.MS0IXhzm-lkp@intel.com/
Signed-off-by: Rakuram Eswaran <rakuram.e96@gmail.com>
---
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 9501def3e0e3e20132fdbcfe0b1f489694afdc5f..284f2eea71e5bf0a34c7fe84084d998164a31a05 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -1681,8 +1681,7 @@ mt7996_msdu_page_get_from_cache(struct mt7996_dev *dev)
if (!list_empty(&dev->wed_rro.page_cache)) {
p = list_first_entry(&dev->wed_rro.page_cache,
struct mt7996_msdu_page, list);
- if (p)
- list_del(&p->list);
+ list_del(&p->list);
}
spin_unlock(&dev->wed_rro.lock);
---
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
change-id: 20251022-mt7996_mac_c-e10894b8bbb4
Best regards,
--
Rakuram Eswaran <rakuram.e96@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache()
2025-10-23 13:04 [PATCH] wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache() Rakuram Eswaran
@ 2025-10-23 13:15 ` Lorenzo Bianconi
2025-10-23 14:24 ` Rakuram Eswaran
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2025-10-23 13:15 UTC (permalink / raw)
To: Rakuram Eswaran
Cc: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
Matthias Brugger, AngeloGioacchino Del Regno, Rex Lu,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek,
david.hunter.linux, khalid, skhan, linux-kernel-mentees,
kernel test robot, Dan Carpenter
[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]
> Smatch reported a warning that the NULL check on `p` in
> `mt7996_msdu_page_get_from_cache()` is redundant:
>
> drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1651
> mt7996_msdu_page_get_from_cache() warn: can 'p' even be NULL?
>
> The function first checks `list_empty(&dev->wed_rro.page_cache)` before
> calling `list_first_entry()`. When the list is not empty,
> `list_first_entry()` always returns a valid pointer and can never be NULL.
>
> Hence, the `if (p)` condition is unnecessary. Removing it cleans up the
> code.
Hi Rakuram,
this issue has been already fixed here:
https://patchwork.kernel.org/project/linux-wireless/patch/20251014-mt7996_msdu_page_get_from_cache-remove-null-ptr-check-v1-1-fbeb7881e192@kernel.org/
Regards,
Lorenzo
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202510100155.MS0IXhzm-lkp@intel.com/
> Signed-off-by: Rakuram Eswaran <rakuram.e96@gmail.com>
> ---
> drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> index 9501def3e0e3e20132fdbcfe0b1f489694afdc5f..284f2eea71e5bf0a34c7fe84084d998164a31a05 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> @@ -1681,8 +1681,7 @@ mt7996_msdu_page_get_from_cache(struct mt7996_dev *dev)
> if (!list_empty(&dev->wed_rro.page_cache)) {
> p = list_first_entry(&dev->wed_rro.page_cache,
> struct mt7996_msdu_page, list);
> - if (p)
> - list_del(&p->list);
> + list_del(&p->list);
> }
>
> spin_unlock(&dev->wed_rro.lock);
>
> ---
> base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
> change-id: 20251022-mt7996_mac_c-e10894b8bbb4
>
> Best regards,
> --
> Rakuram Eswaran <rakuram.e96@gmail.com>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache()
2025-10-23 13:15 ` Lorenzo Bianconi
@ 2025-10-23 14:24 ` Rakuram Eswaran
0 siblings, 0 replies; 3+ messages in thread
From: Rakuram Eswaran @ 2025-10-23 14:24 UTC (permalink / raw)
To: lorenzo
Cc: angelogioacchino.delregno, dan.carpenter, david.hunter.linux,
khalid, linux-arm-kernel, linux-kernel-mentees, linux-kernel,
linux-mediatek, linux-wireless, lkp, matthias.bgg, nbd,
rakuram.e96, rex.lu, ryder.lee, sean.wang, shayne.chen, skhan
On Thu, 23 Oct 2025 at 18:45, Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > Smatch reported a warning that the NULL check on `p` in
> > `mt7996_msdu_page_get_from_cache()` is redundant:
> >
> > drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1651
> > mt7996_msdu_page_get_from_cache() warn: can 'p' even be NULL?
> >
> > The function first checks `list_empty(&dev->wed_rro.page_cache)` before
> > calling `list_first_entry()`. When the list is not empty,
> > `list_first_entry()` always returns a valid pointer and can never be NULL.
> >
> > Hence, the `if (p)` condition is unnecessary. Removing it cleans up the
> > code.
>
> Hi Rakuram,
>
> this issue has been already fixed here:
> https://patchwork.kernel.org/project/linux-wireless/patch/20251014-mt7996_msdu_page_get_from_cache-remove-null-ptr-check-v1-1-fbeb7881e192@kernel.org/
>
> Regards,
> Lorenzo
>
Hello Lorenzo,
Thank you for the information. I did check both linus-mainline and linux-next
branches before sending the patch.
From next time, I’ll make sure to also check the subsystem-specific branches as well.
Thanks again for pointing it out.
Best regards,
Rakuram
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-23 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 13:04 [PATCH] wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache() Rakuram Eswaran
2025-10-23 13:15 ` Lorenzo Bianconi
2025-10-23 14:24 ` Rakuram Eswaran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox