]> git.baikalelectronics.ru Git - 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)
committerDavid S. Miller <davem@davemloft.net>
Sat, 4 May 2019 04:14:46 +0000 (00:14 -0400)
commitf70cc38d4a91bc2dff9687c68c202f6e473f2024
treeae13a1cf879eeca8a20b31d777a7140cd40a699f
parentaeffe6b74dcca25374795bbb0e0e121f06a28377
net: ena: fix: set freed objects to NULL to avoid failing future allocations

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: e59074db59c6 ("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>
drivers/net/ethernet/amazon/ena/ena_netdev.c