Re: [PATCH 04/27] Driver core: devtmpfs: prevent concurrentsubdirectory creation and removal

From: Kay Sievers
Date: Tue Dec 22 2009 - 16:25:46 EST


On Tue, 2009-12-22 at 20:56 +0200, Kirill A. Shutemov wrote:
> On Tue, Dec 22, 2009 at 6:57 PM, Kay Sievers <kay.sievers@xxxxxxxx> wrote:
> > On Tue, Dec 22, 2009 at 15:10, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote:
> >> On Mon, Dec 21, 2009 at 4:37 PM, Kay Sievers <kay.sievers@xxxxxxxx> wrote:
> >>> On Mon, Dec 21, 2009 at 14:37, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote:
> >>>> v2.6.33-rc1-96-gdd59f6c:
> >>>> I guess it can be related to this commit.
> >>>
> >>> The fix is already pending here:
> >>> http://patchwork.kernel.org/patch/68337/
> >>
> >> One more problem: you don't unlock dirlock if kstrdup() failed.
> >
> > Oh right, will send a fix tomorrow.
>
> Reported-by Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>

Thanks!

Kay



From: Kay Sievers <kay.sievers@xxxxxxxx>
Subject: devtmpfs: unlock mutex in case of string allocation error

Reported-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
Signed-off-by: Kay Sievers <kay.sievers@xxxxxxxx>
---
drivers/base/devtmpfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -101,8 +101,10 @@ static int create_path(const char *nodep

/* parent directories do not exist, create them */
path = kstrdup(nodepath, GFP_KERNEL);
- if (!path)
- return -ENOMEM;
+ if (!path) {
+ err = -ENOMEM;
+ goto out;
+ }
s = path;
for (;;) {
s = strchr(s, '/');
@@ -117,6 +119,7 @@ static int create_path(const char *nodep
}
kfree(path);
}
+out:
mutex_unlock(&dirlock);
return err;
}


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