nfs4: Add few lacking error checks after strdup() or malloc()

This commit is contained in:
Pawel Dziepak
2012-07-04 16:52:26 +02:00
parent ea70f0aa5c
commit dd86fd8f4c
2 changed files with 22 additions and 1 deletions
@@ -176,6 +176,11 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
delete[] values;
if (fi.fName == NULL || fi.fPath == NULL) {
delete fs;
return B_NO_MEMORY;
}
Inode* inode;
result = Inode::CreateInode(fs, fi, &inode);
if (result != B_OK) {
@@ -257,6 +262,15 @@ Filesystem::Migrate(const RPC::Server* serv)
free(const_cast<char*>(fPath));
fPath = strdup(locs->fLocations[j].fRootPath);
if (fPath == NULL) {
gRPCServerManager->Release(fServer);
fServer = server;
put_module(DNS_RESOLVER_MODULE_NAME);
delete[] values;
return B_NO_MEMORY;
}
break;
}
}
@@ -265,8 +279,10 @@ Filesystem::Migrate(const RPC::Server* serv)
put_module(DNS_RESOLVER_MODULE_NAME);
delete[] values;
if (server == fServer)
if (server == fServer) {
gRPCServerManager->Release(server);
return B_ERROR;
}
NFS4Server* old = reinterpret_cast<NFS4Server*>(server->PrivateData());
old->RemoveFilesystem(this);
@@ -175,9 +175,14 @@ Inode::LookUp(const char* name, ino_t* id)
fi.fHandle = fh;
fi.fParent = fInfo.fHandle;
fi.fName = strdup(name);
if (fi.fName == NULL)
return B_NO_MEMORY;
char* path = reinterpret_cast<char*>(malloc(strlen(name) + 2 +
strlen(fInfo.fPath)));
if (path == NULL)
return B_NO_MEMORY;
strcpy(path, fInfo.fPath);
strcat(path, "/");
strcat(path, name);