linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mt76: mt7925: main.c: Avoid possible NULL Pointer Dereference in mt7925_change_vif_links()
@ 2024-09-30 18:51 Gax-c
  2024-10-01 19:47 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Gax-c @ 2024-09-30 18:51 UTC (permalink / raw)
  To: nbd, lorenzo, ryder.lee, shayne.chen, sean.wang, kvalo,
	matthias.bgg, angelogioacchino.delregno, deren.wu, mingyen.hsieh
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek, Gax-c,
	Zijie Zhao, Chenyuan Yang

'mconf = devm_kzalloc()' and 'mlink = devm_kzalloc()' may return NULL.
NULL Pointer Dereference may be triggered in the statement 'mconf->link_id = link_id;' below.
Add a null check for the returned pointer.

Fixes: 69acd6d910b0 ("wifi: mt76: mt7925: add mt7925_change_vif_links")
Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zijie Zhao <zzjas98@gmail.com>
Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
 drivers/net/wireless/mediatek/mt76/mt7925/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 791c8b00e112..ea635169497f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1948,6 +1948,12 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 					     GFP_KERNEL);
 		}
 
+		if (!mconf || !mlink) {
+			err = -ENOMEM;
+			goto free;
+		}
+
+
 		mconfs[link_id] = mconf;
 		mlinks[link_id] = mlink;
 		mconf->link_id = link_id;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mt76: mt7925: main.c: Avoid possible NULL Pointer Dereference in mt7925_change_vif_links()
  2024-09-30 18:51 [PATCH] mt76: mt7925: main.c: Avoid possible NULL Pointer Dereference in mt7925_change_vif_links() Gax-c
@ 2024-10-01 19:47 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-01 19:47 UTC (permalink / raw)
  To: Gax-c, nbd, lorenzo, ryder.lee, shayne.chen, sean.wang, kvalo,
	matthias.bgg, angelogioacchino.delregno, deren.wu, mingyen.hsieh
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek, Zijie Zhao,
	Chenyuan Yang

On 30/09/2024 20:51, Gax-c wrote:
> 'mconf = devm_kzalloc()' and 'mlink = devm_kzalloc()' may return NULL.
> NULL Pointer Dereference may be triggered in the statement 'mconf->link_id = link_id;' below.
> Add a null check for the returned pointer.
> 
> Fixes: 69acd6d910b0 ("wifi: mt76: mt7925: add mt7925_change_vif_links")
> Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zijie Zhao <zzjas98@gmail.com>
> Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7925/main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
> index 791c8b00e112..ea635169497f 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
> @@ -1948,6 +1948,12 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>  					     GFP_KERNEL);
>  		}
>  
> +		if (!mconf || !mlink) {
> +			err = -ENOMEM;
> +			goto free;
> +		}
> +

All previous comments apply - wrapping, commit tags, unnecessary blank
lines, proper cleanup.

Best regards,
Krzysztof



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-01 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 18:51 [PATCH] mt76: mt7925: main.c: Avoid possible NULL Pointer Dereference in mt7925_change_vif_links() Gax-c
2024-10-01 19:47 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).