[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 08/36: Fix ENOMEM handling in *_make_peropen
From: |
Samuel Thibault |
Subject: |
[hurd] 08/36: Fix ENOMEM handling in *_make_peropen |
Date: |
Tue, 24 Sep 2013 12:31:13 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit ec62f87ff6fb76b25a3455baa0c92e39aac6b259
Author: Samuel Thibault <address@hidden>
Date: Sat Sep 21 12:54:25 2013 +0200
Fix ENOMEM handling in *_make_peropen
* libdiskfs/peropen-make.c (diskfs_make_peropen): Move `strdup` before port
reference modifications, to fix abortion.
* libnetfs/make-peropen.c (netfs_make_peropen): Check for `malloc` failure.
Move `strdup` before port reference modifications, to fix abortion.
---
libdiskfs/peropen-make.c | 14 +++++++-------
libnetfs/make-peropen.c | 21 +++++++++++++--------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
index b11b2ad..eba037f 100644
--- a/libdiskfs/peropen-make.c
+++ b/libdiskfs/peropen-make.c
@@ -38,6 +38,13 @@ diskfs_make_peropen (struct node *np, int flags, struct
peropen *context,
if (context)
{
+ if (context->path)
+ {
+ po->path = strdup (context->path);
+ if (! po->path)
+ return ENOMEM;
+ }
+
po->root_parent = context->root_parent;
if (po->root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->root_parent,
@@ -51,13 +58,6 @@ diskfs_make_peropen (struct node *np, int flags, struct
peropen *context,
if (po->shadow_root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->shadow_root_parent,
MACH_PORT_RIGHT_SEND, 1);
-
- if (context->path)
- {
- po->path = strdup (context->path);
- if (! po->path)
- return ENOMEM;
- }
}
else
{
diff --git a/libnetfs/make-peropen.c b/libnetfs/make-peropen.c
index 733bfdc..7f2df05 100644
--- a/libnetfs/make-peropen.c
+++ b/libnetfs/make-peropen.c
@@ -25,7 +25,10 @@ struct peropen *
netfs_make_peropen (struct node *np, int flags, struct peropen *context)
{
struct peropen *po = malloc (sizeof (struct peropen));
-
+
+ if (!po)
+ return NULL;
+
po->filepointer = 0;
po->lock_status = LOCK_UN;
po->refcnt = 0;
@@ -35,6 +38,15 @@ netfs_make_peropen (struct node *np, int flags, struct
peropen *context)
if (context)
{
+ if (context->path)
+ {
+ po->path = strdup (context->path);
+ if (! po->path) {
+ free(po);
+ return NULL;
+ }
+ }
+
po->root_parent = context->root_parent;
if (po->root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->root_parent,
@@ -48,13 +60,6 @@ netfs_make_peropen (struct node *np, int flags, struct
peropen *context)
if (po->shadow_root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->shadow_root_parent,
MACH_PORT_RIGHT_SEND, 1);
-
- if (context->path)
- {
- po->path = strdup (context->path);
- if (! po->path)
- return ENOMEM;
- }
}
netfs_nref (np);
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 10/36: Fix gcc warning, (continued)
- [hurd] 10/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 09/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 20/36: Properly return error, Samuel Thibault, 2013/09/24
- [hurd] 19/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 15/36: Fix setting modem control lines, Samuel Thibault, 2013/09/24
- [hurd] 22/36: Rename SOCK_* into PFLOCAL_SOCK_*, Samuel Thibault, 2013/09/24
- [hurd] 13/36: Fix S_tioctl_tiocsetd returning errors, Samuel Thibault, 2013/09/24
- [hurd] 11/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 14/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 25/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 08/36: Fix ENOMEM handling in *_make_peropen,
Samuel Thibault <=
- [hurd] 31/36: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2013/09/24
- [hurd] 07/36: Fix gcc warning:, Samuel Thibault, 2013/09/24
- [hurd] 35/36: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2013/09/24
- [hurd] 34/36: Drop dead links, Samuel Thibault, 2013/09/24
- [hurd] 16/36: Fix gcc warning, Samuel Thibault, 2013/09/24
- [hurd] 32/36: Fix missing renames, Samuel Thibault, 2013/09/24
- [hurd] 29/36: Fix spurious port deallocation, Samuel Thibault, 2013/09/24
- [hurd] 30/36: Add --without-daemon option to configure, Samuel Thibault, 2013/09/24
- [hurd] 36/36: Merge branch 'upstream' of git.debian.org:/git/pkg-hurd/hurd into upstream, Samuel Thibault, 2013/09/24
- [hurd] 12/36: Fix test for term open mode, Samuel Thibault, 2013/09/24