Skip to contentSkip to conversation

ixgbe: correctly handling failed allocation

PATCH In review Insu Yun 2 participants 3 messages Dec 29, 2015 – Dec 30, 2015

Subsystems (3)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 ixgbe: correctly handling failed allocation

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

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -0
index aed8d02..aa5eda0 100644
@@ -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) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Insu Yun

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

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
index aed8d02..aa5eda0 100644
@@ -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) {
--
Quoted 1 line

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

author
#2 lore raw

PATCH 1/1 ixgbe: correctly handling failed allocation

Ok. Thank you.

Quoted 34 lines · Alexander Duyck

Review

Quoted 9 lines · Insu Yun

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

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_sw_init(struct ixgbe_adapter

Quoted 4 lines

index aed8d02..aa5eda0 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -5331,6 +5331,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter

*adapter)

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
        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

Signature · 5 lines
Regards
Insu Yun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20151229/fc04294e/attachment.html>