lkml.org 
[lkml]   [2023]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] fjes: Add missing check for vzalloc
Date

Chen Ni <nichen@iscas.ac.cn> writes:

> 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@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 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;
> +

I'm not sure, but shouldn't this call fjes_hw_cleanup() to mirror the
setup() above? Also only if ret=0 I suppose.

> hw->hw_info.trace_size = FJES_DEBUG_BUFFER_SIZE;
>
> return ret;

\
 
 \ /
  Last update: 2023-09-25 16:45    [W:0.058 / U:2.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site