summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-28 03:31:10 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-28 03:34:54 -0700
commit927aedbb556ee07250248181f52642eeb6de9e58 (patch)
tree034a196708a1c1260951cafeefc42b427bee8479 /libglusterfs/src/fd.c
parent753146c0ff4b1b55892b71b36d6ca97797867aaa (diff)
removed last few remaining 'ERR_ABORT's from codebase
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966
Diffstat (limited to 'libglusterfs/src/fd.c')
-rw-r--r--libglusterfs/src/fd.c29
1 files changed, 22 insertions, 7 deletions
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;
}