Currently, code inside afs_vcache.c assumes that osi_NewVnode always
returns non-NULL, which means that osi_NewVnode must panic if it
cannot create a new vnode.
All of the callers of afs_GetVCache, afs_NewVCache, etc, already
handle getting a NULL return, though (after all, the given fid may not
exist or be inaccessible due to network errors, etc). So, just
propagate NULL returns from osi_NewVnode up to our callers, to avoid
panics in these situations.
Modify osi_NewVnode on many arches to return an error on allocation
failure, instead of panic'ing.
Change-Id: Ib578b1747590bdf65327d4674e0849811ed999eb
Reviewed-on: https://gerrit.openafs.org/13701
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
struct vcache *tvc;
tvc = afs_osi_Alloc(sizeof(struct vcache));
- osi_Assert(tvc != NULL);
+ if (tvc == NULL) {
+ return NULL;
+ }
#ifdef KERNEL_HAVE_PIN
pin((char *)tvc, sizeof(struct vcache)); /* XXX */
struct vcache *tvc;
tvc = afs_osi_Alloc(sizeof(struct vcache));
- osi_Assert(tvc != NULL);
+ if (tvc == NULL) {
+ return NULL;
+ }
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;
struct vcache *tvc;
tvc = afs_osi_Alloc(sizeof(struct vcache));
+ if (tvc == NULL) {
+ return NULL;
+ }
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;
char name[METER_NAMSZ];
avc = afs_osi_Alloc(sizeof(struct vcache));
+ if (avc == NULL) {
+ return NULL;
+ }
memset(avc, 0, sizeof(struct vcache));
avc->v.v_number = ++afsvnumbers;
AFS_GUNLOCK();
ip = new_inode(afs_globalVFS);
- if (!ip)
- osi_Panic("afs_NewVCache: no more inodes");
AFS_GLOCK();
+ if (ip == NULL) {
+ return NULL;
+ }
#if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
tvc = VTOAFS(ip);
#else
tvc = afs_osi_Alloc(sizeof(struct vcache));
+ if (tvc == NULL) {
+ iput(ip);
+ return NULL;
+ }
ip->u.generic_ip = tvc;
tvc->v = ip;
#endif
struct vcache *tvc;
tvc = afs_osi_Alloc(sizeof(struct vcache));
+ if (tvc == NULL) {
+ return NULL;
+ }
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;
struct vcache *tvc;
tvc = afs_osi_Alloc(sizeof(struct vcache));
+ if (tvc == NULL) {
+ return NULL;
+ }
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;
struct vcache *avc;
avc = afs_osi_Alloc(sizeof(struct vcache));
- osi_Assert(avc != NULL);
+ if (avc == NULL) {
+ return NULL;
+ }
return avc;
}
struct vcache *tvc;
tvc = osi_NewVnode();
+ if (tvc == NULL) {
+ return NULL;
+ }
afs_vcount++;
}
}
tvc = afs_AllocVCache();
+ if (tvc == NULL) {
+ return NULL;
+ }
#else /* AFS_LINUX22_ENV */
/* pull out a free cache entry */
if (!freeVCList) {
if (!freeVCList) {
tvc = afs_AllocVCache();
+ if (tvc == NULL) {
+ return NULL;
+ }
} else {
tvc = freeVCList; /* take from free list */
freeVCList = tvc->nextfree;