net: dsa: fix dereference on ds->dev before null check error
authorColin Ian King <colin.king@canonical.com>
Thu, 24 Oct 2019 10:32:18 +0000 (11:32 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Oct 2019 20:38:06 +0000 (13:38 -0700)
commit556f124fb30621df3089d624ac57f13744712753
treeaae66c0e0c71280765c3a66da28a8e6dab2152d5
parent5b7fe93db008ff013db24239136a25f3ac5142ac
net: dsa: fix dereference on ds->dev before null check error

Currently ds->dev is dereferenced on the assignments of pdata and
np before ds->dev is null checked, hence there is a potential null
pointer dereference on ds->dev.  Fix this by assigning pdata and
np after the ds->dev null pointer sanity check.

Addresses-Coverity: ("Dereference before null check")
Fixes: 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa2.c