Skip to content

Commit cc54816

Browse files
error27Joel Becker
authored andcommitted
ocfs2/cluster: dereferencing before checking in nst_seq_show()
In the original code, we dereferenced "nst" before checking that it was non-NULL. I moved the check forward and pulled the code in an indent level. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Joel Becker <joel.becker@oracle.com>
1 parent e70d845 commit cc54816

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

‎fs/ocfs2/cluster/netdebug.c‎

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,36 +133,37 @@ static int nst_seq_show(struct seq_file *seq, void *v)
133133

134134
spin_lock(&o2net_debug_lock);
135135
nst = next_nst(dummy_nst);
136+
if (!nst)
137+
goto out;
136138

137139
now = ktime_get();
138140
sock = ktime_to_us(ktime_sub(now, nst->st_sock_time));
139141
send = ktime_to_us(ktime_sub(now, nst->st_send_time));
140142
status = ktime_to_us(ktime_sub(now, nst->st_status_time));
141143

142-
if (nst != NULL) {
143-
/* get_task_comm isn't exported. oh well. */
144-
seq_printf(seq, "%p:\n"
145-
" pid: %lu\n"
146-
" tgid: %lu\n"
147-
" process name: %s\n"
148-
" node: %u\n"
149-
" sc: %p\n"
150-
" message id: %d\n"
151-
" message type: %u\n"
152-
" message key: 0x%08x\n"
153-
" sock acquiry: %lld usecs ago\n"
154-
" send start: %lld usecs ago\n"
155-
" wait start: %lld usecs ago\n",
156-
nst, (unsigned long)task_pid_nr(nst->st_task),
157-
(unsigned long)nst->st_task->tgid,
158-
nst->st_task->comm, nst->st_node,
159-
nst->st_sc, nst->st_id, nst->st_msg_type,
160-
nst->st_msg_key,
161-
(long long)sock,
162-
(long long)send,
163-
(long long)status);
164-
}
144+
/* get_task_comm isn't exported. oh well. */
145+
seq_printf(seq, "%p:\n"
146+
" pid: %lu\n"
147+
" tgid: %lu\n"
148+
" process name: %s\n"
149+
" node: %u\n"
150+
" sc: %p\n"
151+
" message id: %d\n"
152+
" message type: %u\n"
153+
" message key: 0x%08x\n"
154+
" sock acquiry: %lld usecs ago\n"
155+
" send start: %lld usecs ago\n"
156+
" wait start: %lld usecs ago\n",
157+
nst, (unsigned long)task_pid_nr(nst->st_task),
158+
(unsigned long)nst->st_task->tgid,
159+
nst->st_task->comm, nst->st_node,
160+
nst->st_sc, nst->st_id, nst->st_msg_type,
161+
nst->st_msg_key,
162+
(long long)sock,
163+
(long long)send,
164+
(long long)status);
165165

166+
out:
166167
spin_unlock(&o2net_debug_lock);
167168

168169
return 0;

0 commit comments

Comments
 (0)