[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230925085318.1228225-1-nichen@iscas.ac.cn>
Date: Mon, 25 Sep 2023 08:53:18 +0000
From: Chen Ni <nichen@...as.ac.cn>
To: davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
nichen@...as.ac.cn,
izumi.taku@...fujitsu.com
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] fjes: Add missing check for vzalloc
Because of the potential failure of the vzalloc(), the hw->hw_info.trace
could be NULL.
Therefore, we need to check it and return -ENOMEM in order to transfer
the error.
Fixes: b6ba737d0b29 ("fjes: ethtool -w and -W support for fjes driver")
Signed-off-by: Chen Ni <nichen@...as.ac.cn>
---
drivers/net/fjes/fjes_hw.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index 704e949484d0..3a06a3cf021d 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -330,6 +330,9 @@ int fjes_hw_init(struct fjes_hw *hw)
ret = fjes_hw_setup(hw);
hw->hw_info.trace = vzalloc(FJES_DEBUG_BUFFER_SIZE);
+ if (!hw->hw_info.trace)
+ return -ENOMEM;
+
hw->hw_info.trace_size = FJES_DEBUG_BUFFER_SIZE;
return ret;
--
2.25.1
Powered by blists - more mailing lists