Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
tipc: fix variable dereference before NULL check
Browse files Browse the repository at this point in the history
In commit cf6f7e1 ("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: cf6f7e1 ("tipc: dump monitor attributes")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Parthasarathy Bhuvaragan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Parthasarathy Bhuvaragan authored and davem330 committed Aug 11, 2016
1 parent 293fddf commit 672ca65
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/tipc/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,13 @@ int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
u32 bearer_id, u32 *prev_node)
{
struct tipc_monitor *mon = tipc_monitor(net, bearer_id);
struct tipc_peer *peer = mon->self;
struct tipc_peer *peer;

if (!mon)
return -EINVAL;

read_lock_bh(&mon->lock);
peer = mon->self;
do {
if (*prev_node) {
if (peer->addr == *prev_node)
Expand Down

0 comments on commit 672ca65

Please sign in to comment.