Commit bed6c34b authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

socket: skip unsupported sockets

Before this patch, it stopped if stat() failed.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 64967eef
...@@ -234,6 +234,8 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -234,6 +234,8 @@ static int unix_collect_one(const struct unix_diag_msg *m,
struct rtattr **tb) struct rtattr **tb)
{ {
struct unix_sk_desc *d; struct unix_sk_desc *d;
char *name = NULL;
int ret = 0;
d = xzalloc(sizeof(*d)); d = xzalloc(sizeof(*d));
if (!d) if (!d)
...@@ -248,8 +250,8 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -248,8 +250,8 @@ static int unix_collect_one(const struct unix_diag_msg *m,
if (tb[UNIX_DIAG_NAME]) { if (tb[UNIX_DIAG_NAME]) {
int len = RTA_PAYLOAD(tb[UNIX_DIAG_NAME]); int len = RTA_PAYLOAD(tb[UNIX_DIAG_NAME]);
char *name = xmalloc(len + 1);
name = xmalloc(len + 1);
if (!name) if (!name)
goto err; goto err;
...@@ -263,22 +265,20 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -263,22 +265,20 @@ static int unix_collect_one(const struct unix_diag_msg *m,
if (name[0] != '/') { if (name[0] != '/') {
pr_warn("Relative bind path '%s' " pr_warn("Relative bind path '%s' "
"unsupported\n", name); "unsupported\n", name);
xfree(name); goto skip;
xfree(d);
return 0;
} }
if (!tb[UNIX_DIAG_VFS]) { if (!tb[UNIX_DIAG_VFS]) {
pr_err("Bound socket w/o inode %d\n", pr_err("Bound socket w/o inode %d\n",
m->udiag_ino); m->udiag_ino);
goto err; goto skip;
} }
uv = RTA_DATA(tb[UNIX_DIAG_VFS]); uv = RTA_DATA(tb[UNIX_DIAG_VFS]);
if (stat(name, &st)) { if (stat(name, &st)) {
pr_perror("Can't stat socket %d(%s)", pr_perror("Can't stat socket %d(%s)",
m->udiag_ino, name); m->udiag_ino, name);
goto err; goto skip;
} }
if ((st.st_ino != uv->udiag_vfs_ino) || if ((st.st_ino != uv->udiag_vfs_ino) ||
...@@ -354,12 +354,13 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -354,12 +354,13 @@ static int unix_collect_one(const struct unix_diag_msg *m,
show_one_unix("Collected", d); show_one_unix("Collected", d);
return 0; return 0;
err: err:
ret = -1;
skip:
xfree(d->icons); xfree(d->icons);
xfree(d->name); xfree(name);
xfree(d); xfree(d);
return -1; return ret;
} }
int unix_receive_one(struct nlmsghdr *h) int unix_receive_one(struct nlmsghdr *h)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment