netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Sujuan Chen <sujuan.chen@mediatek.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net v2] net: ethernet: mtk_eth_soc: fix NULL pointer on hw reset
Date: Mon, 21 Aug 2023 18:30:39 +0200	[thread overview]
Message-ID: <ZOORL5HSSSRUxHmQ@lore-desk> (raw)
In-Reply-To: <5465c1609b464cc7407ae1530c40821dcdf9d3e6.1692634266.git.daniel@makrotopia.org>

[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]

> When a hardware reset is triggered on devices not initializing WED the
> calls to mtk_wed_fe_reset and mtk_wed_fe_reset_complete dereference a
> pointer on uninitialized stack memory.
> Break out of both functions in case a hw_list entry is 0.
> 
> Fixes: 08a764a7c51b ("net: ethernet: mtk_wed: add reset/reset_complete callbacks")
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> Changes since v1:
>  * remove unneeded {} initialization for stack allocated memory
> 
>  drivers/net/ethernet/mediatek/mtk_wed.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
> index 00aeee0d5e45f..94376aa2b34c5 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> @@ -222,9 +222,13 @@ void mtk_wed_fe_reset(void)
>  
>  	for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
>  		struct mtk_wed_hw *hw = hw_list[i];
> -		struct mtk_wed_device *dev = hw->wed_dev;
> +		struct mtk_wed_device *dev;
>  		int err;
>  
> +		if (!hw)
> +			break;
> +
> +		dev = hw->wed_dev;
>  		if (!dev || !dev->wlan.reset)
>  			continue;
>  
> @@ -245,8 +249,12 @@ void mtk_wed_fe_reset_complete(void)
>  
>  	for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
>  		struct mtk_wed_hw *hw = hw_list[i];
> -		struct mtk_wed_device *dev = hw->wed_dev;
> +		struct mtk_wed_device *dev;
> +
> +		if (!hw)
> +			break;
>  
> +		dev = hw->wed_dev;
>  		if (!dev || !dev->wlan.reset_complete)
>  			continue;
>  
> -- 
> 2.41.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2023-08-21 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 16:12 [PATCH net v2] net: ethernet: mtk_eth_soc: fix NULL pointer on hw reset Daniel Golle
2023-08-21 16:30 ` Lorenzo Bianconi [this message]
2023-08-22 18:01 ` Jakub Kicinski
2023-08-22 18:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOORL5HSSSRUxHmQ@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sean.wang@mediatek.com \
    --cc=sujuan.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).