wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache()
Subsystems (2)
PATCH 1/1 wifi: mt76: mt7996: remove redundant NULL check in mt7996_msdu_page_get_from_cache()
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.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -2
@@ -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,
Signature · 1 line
Rakuram Eswaran <[email protected]>
Lorenzo Bianconi
maintainerQuoted 6 lines
Smatch reported a warning that the NULL check on
pinmt7996_msdu_page_get_from_cache()is redundant:
drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1651mt7996_msdu_page_get_from_cache()warn: can 'p' even be NULL?
Quoted 6 lines
The function first checks
list_empty(&dev->wed_rro.page_cache)before callinglist_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
Quoted 32 lines
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Rakuram Eswaran <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1
-3@@ -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-e10894b8bbb4Best regards,
Signature · 1 line
Rakuram Eswaran <[email protected]>
Quoted 14 lines · Lorenzo Bianconi
Quoted 7 lines
Smatch reported a warning that the NULL check on
pinmt7996_msdu_page_get_from_cache()is redundant:
drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1651mt7996_msdu_page_get_from_cache()warn: can 'p' even be NULL?Quoted 6 lines
The function first checks
list_empty(&dev->wed_rro.page_cache)before callinglist_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.
Quoted 8 lines
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