From 41e2384181e854c06d3a234c2f37aacf9d92f53c Mon Sep 17 00:00:00 2001 From: Meghana Madhusudhan Date: Tue, 29 Jul 2014 20:20:13 +0530 Subject: nfs-ganesha dumps core when Pynfs tests OPDG1O and OPDG11 are run. Assgining -1 to ret if fd_create fails. The tests somehow enter an error case 'if' block (this will be a separate bug fix), before glfd is created. Need an addiitional check to see if glfd exists before entering the 'else' block in 'out'. glfs_h_creat was missing a similar check, adding that in this bug fix.) Change-Id: I3b69540c53e8169538848b9e7f23ffc8ef0ac189 BUG: 1121062 Signed-off-by: Meghana Madhusudhan Reviewed-on: http://review.gluster.org/8333 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: soumya k Reviewed-by: Vijay Bellur --- api/src/glfs-handleops.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index 0188128f712..cefe6e3157b 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -490,6 +490,7 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) glfd = glfs_fd_new (fs); if (!glfd) { + ret = -1; errno = ENOMEM; goto out; } @@ -509,6 +510,10 @@ glfs_h_open (struct glfs *fs, struct glfs_object *object, int flags) ret = syncop_open (subvol, &loc, flags, glfd->fd); DECODE_SYNCOP_ERR (ret); + glfd->fd->flags = flags; + fd_bind (glfd->fd); + glfs_fd_bind (glfd); + out: loc_wipe (&loc); @@ -518,9 +523,6 @@ out: if (ret && glfd) { glfs_fd_destroy (glfd); glfd = NULL; - } else { - fd_bind (glfd->fd); - glfs_fd_bind (glfd); } glfs_subvol_done (fs, subvol); @@ -583,8 +585,11 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, GLFS_LOC_FILL_PINODE (inode, loc, ret, errno, out, path); glfd = glfs_fd_new (fs); - if (!glfd) - goto out; + if (!glfd) { + ret = -1; + errno = ENOMEM; + goto out; + } glfd->fd = fd_create (loc.inode, getpid()); if (!glfd->fd) { @@ -617,6 +622,10 @@ glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, ret = glfs_create_object (&loc, &object); } + glfd->fd->flags = flags; + fd_bind (glfd->fd); + glfs_fd_bind (glfd); + out: if (ret && object != NULL) { glfs_h_close (object); @@ -631,7 +640,7 @@ out: if (xattr_req) dict_unref (xattr_req); - if (glfd) { + if (ret && glfd) { glfs_fd_destroy (glfd); glfd = NULL; } -- cgit