streams_xattr: Make error handling more obvious
authorVolker Lendecke <vl@samba.org>
Wed, 8 Aug 2018 12:20:58 +0000 (14:20 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 14 Sep 2018 05:49:14 +0000 (07:49 +0200)
Do the NULL check right after the alloc call

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_streams_xattr.c

index 8714007cb8d1028f0fa29f15825c59e7af398d84..0743959e9570a1cd702103523cd538efeef0ae44 100644 (file)
@@ -503,6 +503,11 @@ static int streams_xattr_open(vfs_handle_struct *handle,
 
         sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
                                        xattr_name);
+       if (sio->xattr_name == NULL) {
+               errno = ENOMEM;
+               goto fail;
+       }
+
        /*
         * so->base needs to be a copy of fsp->fsp_name->base_name,
         * making it identical to streams_xattr_recheck(). If the
@@ -512,15 +517,15 @@ static int streams_xattr_open(vfs_handle_struct *handle,
         */
         sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
                                  fsp->fsp_name->base_name);
-       sio->fsp_name_ptr = fsp->fsp_name;
-       sio->handle = handle;
-       sio->fsp = fsp;
-
-       if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
+       if (sio->base == NULL) {
                errno = ENOMEM;
                goto fail;
        }
 
+       sio->fsp_name_ptr = fsp->fsp_name;
+       sio->handle = handle;
+       sio->fsp = fsp;
+
        return fakefd;
 
  fail: