[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix malloc size in tmpfs

From: Carl Fredrik Hammar
Subject: [PATCH] Fix malloc size in tmpfs
Date: Thu, 3 Jun 2010 22:50:32 +0200

* tmpfs/dir.c (diskfs_direnter_hard): Fix malloc size.


Found this little doozy while examining Sergio's patches.  ENTSIZE was
changed back in 2f7f90ce to reflect the size of a struct dirent instead
of a tmpfs_dirent, but NEW is still a tmpfs_dirent...  I just snatched
the old code prior to 2f7f90ce.

It compiles but I'm too lazy to tested it ATM (what with applying patches
and all).  That isn't really necessary in this case, is it?

 tmpfs/dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tmpfs/dir.c b/tmpfs/dir.c
index 25b99bd..2702da5 100644
--- a/tmpfs/dir.c
+++ b/tmpfs/dir.c
@@ -247,7 +247,7 @@ diskfs_direnter_hard (struct node *dp, const char *name,
       > tmpfs_page_limit)
     return ENOSPC;
-  new = malloc (entsize);
+  new = malloc (offsetof (struct tmpfs_dirent, name) + namelen + 1);
   if (new == 0)
     return ENOSPC;
tg: (5923172..) t/tmpfs-fix-dir-malloc (depends on: master)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]