ibmvnic: Fix unchecked return codes of memory allocations
authorThomas Falcon <tlfalcon@linux.ibm.com>
Fri, 7 Jun 2019 21:03:55 +0000 (16:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 Jul 2019 06:11:08 +0000 (08:11 +0200)
[ Upstream commit 7c940b1a5291e5069d561f5b8f0e51db6b7a259a ]

The return values for these memory allocations are unchecked,
which may cause an oops if the driver does not handle them after
a failure. Fix by checking the function's return code.

Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ibm/ibmvnic.c

index b88af81..0ae43d2 100644 (file)
@@ -438,9 +438,10 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
                if (rx_pool->buff_size != be64_to_cpu(size_array[i])) {
                        free_long_term_buff(adapter, &rx_pool->long_term_buff);
                        rx_pool->buff_size = be64_to_cpu(size_array[i]);
-                       alloc_long_term_buff(adapter, &rx_pool->long_term_buff,
-                                            rx_pool->size *
-                                            rx_pool->buff_size);
+                       rc = alloc_long_term_buff(adapter,
+                                                 &rx_pool->long_term_buff,
+                                                 rx_pool->size *
+                                                 rx_pool->buff_size);
                } else {
                        rc = reset_long_term_buff(adapter,
                                                  &rx_pool->long_term_buff);
@@ -706,9 +707,9 @@ static int init_tx_pools(struct net_device *netdev)
                        return rc;
                }
 
-               init_one_tx_pool(netdev, &adapter->tso_pool[i],
-                                IBMVNIC_TSO_BUFS,
-                                IBMVNIC_TSO_BUF_SZ);
+               rc = init_one_tx_pool(netdev, &adapter->tso_pool[i],
+                                     IBMVNIC_TSO_BUFS,
+                                     IBMVNIC_TSO_BUF_SZ);
                if (rc) {
                        release_tx_pools(adapter);
                        return rc;