tipc: fix variable dereference before NULL check
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Wed, 10 Aug 2016 12:07:34 +0000 (14:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Aug 2016 00:56:52 +0000 (17:56 -0700)
commit672ca65d9aa8578f382784fe73578cd499664828
treeb3b016c578ca225e824a3317ddf5e94ac6bdf5d6
parent293fddff20cd6d1adf2bd59cda1f5b5e7199104a
tipc: fix variable dereference before NULL check

In commit cf6f7e1d5109 ("tipc: dump monitor attributes"),
I dereferenced a pointer before checking if its valid.
This is reported by static check Smatch as:
net/tipc/monitor.c:733 tipc_nl_add_monitor_peer()
     warn: variable dereferenced before check 'mon' (see line 731)

In this commit, we check for a valid monitor before proceeding
with any other operation.

Fixes: cf6f7e1d5109 ("tipc: dump monitor attributes")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/monitor.c