]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
net: ena: fix: set freed objects to NULL to avoid failing future allocations
authorSameeh Jubran <sameehj@amazon.com>
Wed, 1 May 2019 13:47:04 +0000 (16:47 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 13 Nov 2019 17:07:36 +0000 (18:07 +0100)
commited0655c0252fc7d6275a2da1a16d43356b0cad34
treec964b67ccbb565a558789f85277ba8fd2f227b34
parent6de30fc3a9d930f9d58debfb381d4a545a303071
net: ena: fix: set freed objects to NULL to avoid failing future allocations

BugLink: https://bugs.launchpad.net/bugs/1850175
In some cases when a queue related allocation fails, successful past
allocations are freed but the pointer that pointed to them is not
set to NULL. This is a problem for 2 reasons:
1. This is generally a bad practice since this pointer might be
accidentally accessed in the future.
2. Future allocations using the same pointer check if the pointer
is NULL and fail if it is not.

Fixed this by setting such pointers to NULL in the allocation of
queue related objects.

Also refactored the code of ena_setup_tx_resources() to goto-style
error handling to avoid code duplication of resource freeing.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 8ee8ee7fe87bf64738ab4e31be036a7165608b27)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Khaled Elmously <khalid.elmously@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/amazon/ena/ena_netdev.c