Re: proc: proc_self_follow_link() weirdness

From: Cyrill Gorcunov
Date: Sun Nov 28 2010 - 16:55:16 EST


On Sun, Nov 28, 2010 at 09:09:03PM +0100, Vegard Nossum wrote:
> 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

nd_get_link callers do check for IS_ERR (directly or indirectly),
but to return 'name' here would be more appropriate I guess. Al?

Cyrill
--
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/