[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1652957839-127949-1-git-send-email-lyz_cs@pku.edu.cn>
Date:   Thu, 19 May 2022 03:57:19 -0700
From:   Yongzhi Liu <lyz_cs@....edu.cn>
To:     amitkarwar@...il.com, ganapathi017@...il.com,
        sharvari.harisangam@....com, huxinming820@...il.com,
        kvalo@...nel.org, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, pabeni@...hat.com, arend.vanspriel@...adcom.com
Cc:     linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, fuyq@....pku.edu.cn,
        Yongzhi Liu <lyz_cs@....edu.cn>
Subject: [PATCH] mwifiex:  Fix potential dereference of NULL pointer
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@....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
Powered by blists - more mailing lists