From: Paolo Abeni <pabeni@redhat.com>
To: Petr Machata <petrm@nvidia.com>, Chen Ni <nichen@iscas.ac.cn>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
izumi.taku@jp.fujitsu.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fjes: Add missing check for vzalloc
Date: Tue, 03 Oct 2023 13:07:35 +0200 [thread overview]
Message-ID: <018982972b43bdac3f6d50bde03287282364e357.camel@redhat.com> (raw)
In-Reply-To: <87r0mms4a5.fsf@nvidia.com>
On Mon, 2023-09-25 at 16:40 +0200, Petr Machata wrote:
> 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.
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
prev parent reply other threads:[~2023-10-03 11:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 8:53 Chen Ni
2023-09-25 14:40 ` Petr Machata
2023-10-03 11:07 ` Paolo Abeni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=018982972b43bdac3f6d50bde03287282364e357.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nichen@iscas.ac.cn \
--cc=petrm@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®