From 927aedbb556ee07250248181f52642eeb6de9e58 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 28 Jul 2010 03:31:10 +0000 Subject: removed last few remaining 'ERR_ABORT's from codebase Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966 --- libglusterfs/src/fd.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'libglusterfs/src/fd.c') diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index d26854ebdfb..9269e5cf838 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -87,10 +87,12 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr) { fdentry_t *oldfds = NULL; uint32_t oldmax_fds = -1; + int ret = -1; if (fdtable == NULL || nr < 0) { gf_log ("fd", GF_LOG_ERROR, "invalid argument"); - return EINVAL; + ret = EINVAL; + goto out; } nr /= (1024 / sizeof (fdentry_t)); @@ -102,7 +104,10 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr) fdtable->fdentries = GF_CALLOC (nr, sizeof (fdentry_t), gf_common_mt_fdentry_t); - ERR_ABORT (fdtable->fdentries); + if (!fdtable->fdentries) { + ret = ENOMEM; + goto out; + } fdtable->max_fds = nr; if (oldfds) { @@ -119,7 +124,9 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr) */ fdtable->first_free = oldmax_fds; GF_FREE (oldfds); - return 0; + ret = 0; +out: + return ret; } @@ -499,11 +506,17 @@ fd_create (inode_t *inode, pid_t pid) } fd = GF_CALLOC (1, sizeof (fd_t), gf_common_mt_fd_t); - ERR_ABORT (fd); + if (!fd) + goto out; - fd->_ctx = GF_CALLOC (1, (sizeof (struct _fd_ctx) * + fd->_ctx = GF_CALLOC (1, (sizeof (struct _fd_ctx) * inode->table->xl->graph->xl_count), gf_common_mt_fd_ctx); + if (!fd->_ctx) { + GF_FREE (fd); + fd = NULL; + goto out; + } fd->inode = inode_ref (inode); fd->pid = pid; @@ -512,9 +525,11 @@ fd_create (inode_t *inode, pid_t pid) LOCK_INIT (&fd->lock); LOCK (&inode->lock); - fd = _fd_ref (fd); + { + fd = _fd_ref (fd); + } UNLOCK (&inode->lock); - +out: return fd; } -- cgit