Re: [PATCH] vfs: use kstrdup()
From: Al Viro
Date: Mon Jul 21 2008 - 01:27:28 EST
On Sat, Jul 19, 2008 at 05:19:09PM +0400, Cyrill Gorcunov wrote:
> [Cyrill Gorcunov - Sat, Jul 19, 2008 at 05:13:17PM +0400]
> [...]
> | | - }
> | | - }
> | | + mnt->mnt_devname = kstrdup(name, GFP_KERNEL);
> | | }
> | | return mnt;
> | | }
> | | --
> | | 1.5.4.rc3
> | |
> | |
> |
> | but kstrdup may return NULL - is it safe there?
> | Sorry if that "not smart" question.
> |
> | - Cyrill -
>
> ah, I see it is safe - sorry for noise
FWIW, it _is_ a good question.
* is all code treating ->mnt_devname as optional? AFAICS, there's
at least one place in NFS that doesn't. We could treat failing allocation
the same way we treat failing allocation of vfsmount itself - callers can
cope with that already.
* AFAICS, it should be const char *.
* ... or perhaps we shouldn't copy it at all. How about something
like
struct {
int count;
char name[];
}
with cloning sharing the reference and bumping the count, protecting it with
e.g. vfsmount_lock? For setups where we have a lot of bindings/namespaces
it might be noticable.
Any takers?
--
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/