proc: proc_self_follow_link() weirdness

From: Vegard Nossum
Date: Sun Nov 28 2010 - 15:09:12 EST


Hi,

I came across this code in fs/proc/base.c:

static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
{
struct pid_namespace *ns = dentry->d_sb->s_fs_info;
pid_t tgid = task_tgid_nr_ns(current, ns);
char *name = ERR_PTR(-ENOENT);
if (tgid) {
name = __getname();
if (!name)
name = ERR_PTR(-ENOMEM);
else
sprintf(name, "%d", tgid);
}
nd_set_link(nd, name);
return NULL;
}

This looks a bit weird to me; it seems that nd_set_link() will get
called with name = ERR_PTR(-ENOMEM) if __getname() fails. Is this the
intended behaviour? Shouldn't it return this ERR_PTR() instead?


Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/