diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -1164,8 +1164,14 @@ f = RB_FIND(files_t, &ftree, &(struct file){ .xf_data = p->socket }); - pos += xprintf("[%lu %d]", - (u_long)f->xf_pid, f->xf_fd); + if (__predict_false(f == NULL)) + /* Known to happen when a dgram + * socket is open in the kernel, + * gssd.sock for example */ + pos += xprintf("??"); + else + pos += xprintf("[%lu %d]", + (u_long)f->xf_pid, f->xf_fd); } else pos += printaddr(&p->laddr->address); }