]> git.baikalelectronics.ru Git - kernel.git/commit
net: ena: ena-com.c: prevent NULL pointer dereference
authorArthur Kiyanovski <akiyano@amazon.com>
Tue, 11 Feb 2020 15:17:51 +0000 (15:17 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Feb 2020 01:08:31 +0000 (17:08 -0800)
commit548ec31e3fbf4e5fcf1e38ae789ad40d53e58b70
tree5635ba5e41e1cd608c8ad4977c18bdadee3fe588
parenta7ad6718fa2ab380d504bc8ed53395d3e6cf2ce0
net: ena: ena-com.c: prevent NULL pointer dereference

comp_ctx can be NULL in a very rare case when an admin command is executed
during the execution of ena_remove().

The bug scenario is as follows:

* ena_destroy_device() sets the comp_ctx to be NULL
* An admin command is executed before executing unregister_netdev(),
  this can still happen because our device can still receive callbacks
  from the netdev infrastructure such as ethtool commands.
* When attempting to access the comp_ctx, the bug occurs since it's set
  to NULL

Fix:
Added a check that comp_ctx is not NULL

Fixes: e59074db59c6 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amazon/ena/ena_com.c