linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] net: hns3: Fix potential null pointer defererence of null ae_dev
@ 2021-04-09 16:37 Colin King
  2021-04-12 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-04-09 16:37 UTC (permalink / raw)
  To: Yisen Zhuang, Salil Mehta, David S . Miller, Jakub Kicinski,
	Huazhong Tan, Jiaran Zhang, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The reset_prepare and reset_done calls have a null pointer check
on ae_dev however ae_dev is being dereferenced via the call to
ns3_is_phys_func with the ae->pdev argument. Fix this by performing
a null pointer check on ae_dev and hence short-circuiting the
dereference to ae_dev on the call to ns3_is_phys_func.

Addresses-Coverity: ("Dereference before null check")
Fixes: 715c58e94f0d ("net: hns3: add suspend and resume pm_ops")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 25afe5a3348c..c21dd11baed9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2369,9 +2369,9 @@ static int __maybe_unused hns3_suspend(struct device *dev)
 {
 	struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
 
-	if (hns3_is_phys_func(ae_dev->pdev)) {
+	if (ae_dev && hns3_is_phys_func(ae_dev->pdev)) {
 		dev_info(dev, "Begin to suspend.\n");
-		if (ae_dev && ae_dev->ops && ae_dev->ops->reset_prepare)
+		if (ae_dev->ops && ae_dev->ops->reset_prepare)
 			ae_dev->ops->reset_prepare(ae_dev, HNAE3_FUNC_RESET);
 	}
 
@@ -2382,9 +2382,9 @@ static int __maybe_unused hns3_resume(struct device *dev)
 {
 	struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
 
-	if (hns3_is_phys_func(ae_dev->pdev)) {
+	if (ae_dev && hns3_is_phys_func(ae_dev->pdev)) {
 		dev_info(dev, "Begin to resume.\n");
-		if (ae_dev && ae_dev->ops && ae_dev->ops->reset_done)
+		if (ae_dev->ops && ae_dev->ops->reset_done)
 			ae_dev->ops->reset_done(ae_dev);
 	}
 
-- 
2.30.2


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

* Re: [PATCH][next] net: hns3: Fix potential null pointer defererence of null ae_dev
  2021-04-09 16:37 [PATCH][next] net: hns3: Fix potential null pointer defererence of null ae_dev Colin King
@ 2021-04-12 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-12 20:20 UTC (permalink / raw)
  To: Colin Ian King
  Cc: yisen.zhuang, salil.mehta, davem, kuba, tanhuazhong, zhangjiaran,
	netdev, kernel-janitors, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri,  9 Apr 2021 17:37:26 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The reset_prepare and reset_done calls have a null pointer check
> on ae_dev however ae_dev is being dereferenced via the call to
> ns3_is_phys_func with the ae->pdev argument. Fix this by performing
> a null pointer check on ae_dev and hence short-circuiting the
> dereference to ae_dev on the call to ns3_is_phys_func.
> 
> [...]

Here is the summary with links:
  - [next] net: hns3: Fix potential null pointer defererence of null ae_dev
    https://git.kernel.org/netdev/net-next/c/d0494135f94c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-04-12 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 16:37 [PATCH][next] net: hns3: Fix potential null pointer defererence of null ae_dev Colin King
2021-04-12 20:20 ` patchwork-bot+netdevbpf

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