From: "Waskiewicz Jr, Peter" <peter.waskiewicz.jr@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
"Kirsher, Jeffrey T" <jeffrey.t.kirsher@intel.com>
Cc: "intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] igb: check memory allocation failure
Date: Sun, 27 Aug 2017 23:09:12 +0000 [thread overview]
Message-ID: <E0D909EE5BB15A4699798539EA149D7F0779685B@ORSMSX103.amr.corp.intel.com> (raw)
In-Reply-To: 20170827063951.5975-1-christophe.jaillet@wanadoo.fr
On 8/27/17 2:42 AM, Christophe JAILLET wrote:
> Check memory allocation failures and return -ENOMEM in such cases, as
> already done for other memory allocations in this function.
>
> This avoids NULL pointers dereference.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/net/ethernet/intel/igb/igb_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index fd4a46b03cc8..837d9b46a390 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3162,6 +3162,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
> /* Setup and initialize a copy of the hw vlan table array */
> adapter->shadow_vfta = kcalloc(E1000_VLAN_FILTER_TBL_SIZE, sizeof(u32),
> GFP_ATOMIC);
> + if (!adapter->shadow_vfta)
> + return -ENOMEM;
Looks reasonable to me.
A larger issue though I see in this function is that if we return
-ENOMEM here, and if we return -ENOMEM from igb_init_interrupt_scheme()
below on failure, we leak adapter->mac_table (and adapter->shadow_vfta
in the latter). We should add a proper unwind to free up the memory on
failure.
-PJ
next prev parent reply other threads:[~2017-08-27 23:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-27 6:39 [PATCH] igb: check memory allocation failure Christophe JAILLET
2017-08-27 23:09 ` Waskiewicz Jr, Peter [this message]
2017-08-28 17:12 ` Christophe JAILLET
2017-09-14 2:24 ` [Intel-wired-lan] " Brown, Aaron F
2017-09-14 14:47 ` Waskiewicz Jr, Peter
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=E0D909EE5BB15A4699798539EA149D7F0779685B@ORSMSX103.amr.corp.intel.com \
--to=peter.waskiewicz.jr@intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jeffrey.t.kirsher@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).