cifs: check kzalloc return
authorJoe Perches <joe@perches.com>
Fri, 21 Dec 2018 05:50:48 +0000 (23:50 -0600)
committerSteve French <stfrench@microsoft.com>
Fri, 28 Dec 2018 16:09:46 +0000 (10:09 -0600)
commit0544b324e62c177c3a9e9c3bdce22e6db9f34588
tree889b401a257a882a6a4882192b8726e75c87677b
parent29cbfa1b2be2e51785f871351d321896861f2ce8
cifs: check kzalloc return

kzalloc can return NULL so an additional check is needed. While there
is a check for ret_buf there is no check for the allocation of
ret_buf->crfid.fid - this check is thus added. Both call-sites
of tconInfoAlloc() check for NULL return of tconInfoAlloc()
so returning NULL on failure of kzalloc() here seems appropriate.
As the kzalloc() is the only thing here that can fail it is
moved to the beginning so as not to initialize other resources
on failure of kzalloc.

Fixes: 3d4ef9a15343 ("smb3: fix redundant opens on root")
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/misc.c