]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ibmvnic: free tx_pool if tso_pool alloc fails
authorSukadev Bhattiprolu <sukadev@linux.ibm.com>
Thu, 24 Jun 2021 04:13:15 +0000 (21:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 15:00:03 +0000 (17:00 +0200)
[ Upstream commit f6ebca8efa52e4ae770f0325d618e7bcf08ada0c ]

Free tx_pool and clear it, if allocation of tso_pool fails.

release_tx_pools() assumes we have both tx and tso_pools if ->tx_pool is
non-NULL. If allocation of tso_pool fails in init_tx_pools(), the assumption
will not be true and we would end up dereferencing ->tx_buff, ->free_map
fields from a NULL pointer.

Fixes: 3205306c6b8d ("ibmvnic: Update TX pool initialization routine")
Signed-off-by: Sukadev Bhattiprolu <sukadev@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 accf362193f8b0932b1d995dccacac159353f42d..3c77897b3f31f1c31b4678765b69d99f1cfcc7a4 100644 (file)
@@ -778,8 +778,11 @@ static int init_tx_pools(struct net_device *netdev)
 
        adapter->tso_pool = kcalloc(tx_subcrqs,
                                    sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
-       if (!adapter->tso_pool)
+       if (!adapter->tso_pool) {
+               kfree(adapter->tx_pool);
+               adapter->tx_pool = NULL;
                return -1;
+       }
 
        adapter->num_active_tx_pools = tx_subcrqs;