linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mwifiex:  Fix potential dereference of NULL pointer
@ 2022-05-19 10:57 Yongzhi Liu
  2022-05-19 15:37 ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Yongzhi Liu @ 2022-05-19 10:57 UTC (permalink / raw)
  To: amitkarwar, ganapathi017, sharvari.harisangam, huxinming820,
	kvalo, davem, edumazet, kuba, pabeni, arend.vanspriel
  Cc: linux-wireless, netdev, linux-kernel, fuyq, Yongzhi Liu

If 'card' is not valid, then we need to check the
field 'adapter' and 'priv_num' to avoid use of NULL
pointer in function 'mwifiex_get_priv'. Fix this by
adding the null pointer check on them.

Fixes: 21c5c83ce ("mwifiex: support sysfs initiated device coredump")

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
---
 drivers/net/wireless/marvell/mwifiex/usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 8f01fcb..c635206 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -686,6 +686,8 @@ static void mwifiex_usb_coredump(struct device *dev)
 {
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct usb_card_rec *card = usb_get_intfdata(intf);
+	if (!card->adapter || !card->adapter->priv_num)
+		return;
 
 	mwifiex_fw_dump_event(mwifiex_get_priv(card->adapter,
 					       MWIFIEX_BSS_ROLE_ANY));
-- 
2.7.4


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

* Re: [PATCH] mwifiex:  Fix potential dereference of NULL pointer
  2022-05-19 10:57 [PATCH] mwifiex: Fix potential dereference of NULL pointer Yongzhi Liu
@ 2022-05-19 15:37 ` Kalle Valo
  2022-05-19 15:52   ` Jeff Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Kalle Valo @ 2022-05-19 15:37 UTC (permalink / raw)
  To: Yongzhi Liu
  Cc: amitkarwar, ganapathi017, sharvari.harisangam, huxinming820,
	davem, edumazet, kuba, pabeni, arend.vanspriel, linux-wireless,
	netdev, linux-kernel, fuyq

Yongzhi Liu <lyz_cs@pku.edu.cn> writes:

> If 'card' is not valid, then we need to check the
> field 'adapter' and 'priv_num' to avoid use of NULL
> pointer in function 'mwifiex_get_priv'. Fix this by
> adding the null pointer check on them.

Why? We don't add null checks for every access, why does this function
need it?

How did you find this? Is this something you found with a static checker
tool or by testing with a real device?

> Fixes: 21c5c83ce ("mwifiex: support sysfs initiated device coredump")

Format is wrong, it should be:

Fixes: 21c5c83ce833 ("mwifiex: support sysfs initiated device coredump")

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH] mwifiex: Fix potential dereference of NULL pointer
  2022-05-19 15:37 ` Kalle Valo
@ 2022-05-19 15:52   ` Jeff Johnson
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Johnson @ 2022-05-19 15:52 UTC (permalink / raw)
  To: Kalle Valo, Yongzhi Liu
  Cc: amitkarwar, ganapathi017, sharvari.harisangam, huxinming820,
	davem, edumazet, kuba, pabeni, arend.vanspriel, linux-wireless,
	netdev, linux-kernel, fuyq

On 5/19/2022 8:37 AM, Kalle Valo wrote:
> Yongzhi Liu <lyz_cs@pku.edu.cn> writes:
> Format is wrong, it should be:
> 
> Fixes: 21c5c83ce833 ("mwifiex: support sysfs initiated device coredump")

And no blank line between the Fixes tag and the Signed-off-by tag


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

end of thread, other threads:[~2022-05-19 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 10:57 [PATCH] mwifiex: Fix potential dereference of NULL pointer Yongzhi Liu
2022-05-19 15:37 ` Kalle Valo
2022-05-19 15:52   ` Jeff Johnson

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).