]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:43:15 +0000 (06:43 -0700)
commit7a154742b667b29e93becb7ce19b8dd893b66109
treec5458eeefebd7f398ad6357f2699a8f117d90a01
parent93504109f9ffc222ad585efbd830b55325cff47f
net: ena: fix: set freed objects to NULL to avoid failing future allocations

[ Upstream commit 8ee8ee7fe87bf64738ab4e31be036a7165608b27 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/amazon/ena/ena_netdev.c