]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
net: ep93xx_eth: Do not crash unloading module
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 5 Dec 2016 03:22:05 +0000 (19:22 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Dec 2016 20:35:39 +0000 (15:35 -0500)
commitc823abac17926767fb50175e098f087a6ac684c3
tree82887ccb88651b5a77598d26a65eb555ab21ae38
parent34e0f2c2d82d7d939bfa249672311050b3b537f1
net: ep93xx_eth: Do not crash unloading module

When we unload the ep93xx_eth, whether we have opened the network
interface or not, we will either hit a kernel paging request error, or a
simple NULL pointer de-reference because:

- if ep93xx_open has been called, we have created a valid DMA mapping
  for ep->descs, when we call ep93xx_stop, we also call
  ep93xx_free_buffers, ep->descs now has a stale value

- if ep93xx_open has not been called, we have a NULL pointer for
  ep->descs, so performing any operation against that address just won't
  work

Fix this by adding a NULL pointer check for ep->descs which means that
ep93xx_free_buffers() was able to successfully tear down the descriptors
and free the DMA cookie as well.

Fixes: 1d22e05df818 ("[PATCH] Cirrus Logic ep93xx ethernet driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cirrus/ep93xx_eth.c