netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ixgbe: correctly handling failed allocation
@ 2015-12-29 21:55 Insu Yun
  2015-12-29 23:51 ` Alexander Duyck
  0 siblings, 1 reply; 2+ messages in thread
From: Insu Yun @ 2015-12-29 21:55 UTC (permalink / raw)
  To: jeffrey.t.kirsher, jesse.brandeburg, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, bruce.w.allan, john.ronciak,
	mitch.a.williams, intel-wired-lan, netdev, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

Since kzalloc can be failed in memory pressure,
NULL derefence could be happened.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index aed8d02..aa5eda0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -5331,6 +5331,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)
 	adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) *
 				     hw->mac.num_rar_entries,
 				     GFP_ATOMIC);
+	if (!adapter->mac_table)
+		return -ENOMEM;
 
 	/* Set MAC specific capability flags and exceptions */
 	switch (hw->mac.type) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ixgbe: correctly handling failed allocation
  2015-12-29 21:55 [PATCH] ixgbe: correctly handling failed allocation Insu Yun
@ 2015-12-29 23:51 ` Alexander Duyck
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Duyck @ 2015-12-29 23:51 UTC (permalink / raw)
  To: Insu Yun
  Cc: Jeff Kirsher, Brandeburg, Jesse, shannon nelson, Carolyn Wyborny,
	Skidmore, Donald C, Allan, Bruce W, Ronciak, John, Mitch Williams,
	intel-wired-lan, Netdev, linux-kernel@vger.kernel.org, taesoo,
	yeongjin.jang, insu, changwoo

On Tue, Dec 29, 2015 at 1:55 PM, Insu Yun <wuninsu@gmail.com> wrote:
> Since kzalloc can be failed in memory pressure,
> NULL derefence could be happened.
>
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index aed8d02..aa5eda0 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -5331,6 +5331,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)
>         adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) *
>                                      hw->mac.num_rar_entries,
>                                      GFP_ATOMIC);
> +       if (!adapter->mac_table)
> +               return -ENOMEM;
>
>         /* Set MAC specific capability flags and exceptions */
>         switch (hw->mac.type) {
> --
> 1.9.1

That change is already present in the current net-next.

Take a look at commit 530fd82a9fea ("ixgbe: Return error on failure to
allocate mac_table").

- Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-29 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-29 21:55 [PATCH] ixgbe: correctly handling failed allocation Insu Yun
2015-12-29 23:51 ` Alexander Duyck

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).