diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-01-07 17:06:26 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2001-01-07 17:06:26 +0000 |
commit | 1b062b32391b5ec34652853eddaa79ab9d625cc1 (patch) | |
tree | 5bb37887def6090ac81768871deaededab369c22 /isofs/inode.c | |
parent | 1f2c071fb4b9f8f9b3184ecd4f05bb6dde830984 (diff) |
2000-12-21 Marcus Brinkmann <marcus@gnu.org>
* rr.c (rrip_work): Use strdup instead malloc and strcpy.
Assert that strdup and malloc (for rr->trans) succeeds.
* pager.c: Include <errno.h>.
(create_disk_pager): If malloc fails, exit with error.
* main.c (read_sblock): Fail if malloc does.
* inode.c (diskfs_cached_lookup): When allocating memory for dn or
np fails, release spinlock, rrip (and allocated memory) and return
ENOMEM.
(load_inode): Likewise (but no rrip). Also, if *npp is non-zero,
release diskfs_node_refcnt_lock before returning.
Reported by Igor Khavkine <i_khavki@alcor.concordia.ca>.
Diffstat (limited to 'isofs/inode.c')
-rw-r--r-- | isofs/inode.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/isofs/inode.c b/isofs/inode.c index 2aa73a93..f3b04c7d 100644 --- a/isofs/inode.c +++ b/isofs/inode.c @@ -188,10 +188,23 @@ diskfs_cached_lookup (int id, struct node **npp) assert (!(rr.valid & VALID_CL)); dn = malloc (sizeof (struct disknode)); + if (!dn) + { + spin_unlock (&diskfs_node_refcnt_lock); + release_rrip (&rr); + return ENOMEM; + } dn->fileinfo = 0; dn->dr = c->dr; dn->file_start = c->file_start; np = diskfs_make_node (dn); + if (!np) + { + free (dn); + spin_unlock (&diskfs_node_refcnt_lock); + release_rrip (&rr); + return ENOMEM; + } np->cache_id = id + 1; /* see above for rationale for increment */ mutex_lock (&np->lock); c->np = np; @@ -327,15 +340,29 @@ load_inode (struct node **npp, struct dirrect *record, inode_cache_find ((off_t) ((void *) record - (void *) disk_image), npp); if (*npp) - return 0; + { + spin_unlock (&diskfs_node_refcnt_lock); + return 0; + } /* Create a new node */ dn = malloc (sizeof (struct disknode)); + if (!dn) + { + spin_unlock (&diskfs_node_refcnt_lock); + return ENOMEM; + } dn->fileinfo = 0; dn->dr = record; dn->file_start = file_start; np = diskfs_make_node (dn); + if (!np) + { + free (dn); + spin_unlock (&diskfs_node_refcnt_lock); + return ENOMEM; + } mutex_lock (&np->lock); |