staging: fsl-dpaa2: ethsw: Add missing netdevice check
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 22 Feb 2019 22:02:14 +0000 (14:02 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Feb 2019 10:52:46 +0000 (11:52 +0100)
port_switchdev_event() does not check that the target network device is
actually backed by the ethsw driver, this could be problematic in a
stacked environment case.

Fixes: 44baaa43d7cc ("staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fsl-dpaa2/ethsw/ethsw.c

index daabace..2edd82f 100644 (file)
@@ -1047,6 +1047,9 @@ static int port_switchdev_event(struct notifier_block *unused,
        struct ethsw_switchdev_event_work *switchdev_work;
        struct switchdev_notifier_fdb_info *fdb_info = ptr;
 
+       if (!ethsw_port_dev_check(dev))
+               return NOTIFY_DONE;
+
        switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
        if (!switchdev_work)
                return NOTIFY_BAD;