xfrm: check for xdo_dev_state_free
authorShannon Nelson <shannon.nelson@oracle.com>
Tue, 19 Dec 2017 23:35:47 +0000 (15:35 -0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 21 Dec 2017 07:17:48 +0000 (08:17 +0100)
The current XFRM code assumes that we've implemented the
xdo_dev_state_free() callback, even if it is meaningless to the driver.
This patch adds a check for it before calling, as done in other APIs,
to prevent a NULL function pointer kernel crash.

Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h

index 357764a2bb4e4dbe11fc50220a9f50434c7cfad1..079ea9455bcd78cbd78a695452b59d03b42887cd 100644 (file)
@@ -1933,7 +1933,8 @@ static inline void xfrm_dev_state_free(struct xfrm_state *x)
         struct net_device *dev = xso->dev;
 
        if (dev && dev->xfrmdev_ops) {
-               dev->xfrmdev_ops->xdo_dev_state_free(x);
+               if (dev->xfrmdev_ops->xdo_dev_state_free)
+                       dev->xfrmdev_ops->xdo_dev_state_free(x);
                xso->dev = NULL;
                dev_put(dev);
        }