lkml.org 
[lkml]   [2021]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] fjes: Check possible NULL pointer returned by vzalloc
Date
As the possible alloc failure of the vzalloc(), the 'hw->hw_info.trace'
could be NULL pointer.
Therefore it should be better to check it to guarantee the complete
success of the initiation.

Fixes: 8cdc3f6c5d22 ("fjes: Hardware initialization routine")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.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 065bb0a40b1d..4c83f637a135 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -329,6 +329,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
\
 
 \ /
  Last update: 2021-12-29 11:22    [W:0.478 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site