lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <018982972b43bdac3f6d50bde03287282364e357.camel@redhat.com>
Date:   Tue, 03 Oct 2023 13:07:35 +0200
From:   Paolo Abeni <pabeni@...hat.com>
To:     Petr Machata <petrm@...dia.com>, Chen Ni <nichen@...as.ac.cn>
Cc:     davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        izumi.taku@...fujitsu.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fjes: Add missing check for vzalloc

On Mon, 2023-09-25 at 16:40 +0200, Petr Machata wrote:
> Chen Ni <nichen@...as.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@...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;
> > +
> 
> I'm not sure, but shouldn't this call fjes_hw_cleanup() to mirror the
> setup() above? Also only if ret=0 I suppose.

Yes, that looks needed, or memory will be leaked. Additionally it looks
like the rest of the driver handles correctly the case where
hw_info.trace is NULL, so this fix is likely not needed at all.

Cheers,

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ