]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/mount: check before dereference buf
authorsongweibin <song.weibin@zte.com.cn>
Thu, 25 Jul 2019 11:05:33 +0000 (19:05 +0800)
committersongweibin <song.weibin@zte.com.cn>
Fri, 26 Jul 2019 06:27:02 +0000 (14:27 +0800)
CID 180671 (#1 of 1): Dereference null return value (NULL_RETURNS)

Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/mount/mount.ceph.c

index 1345e7f451257771666bee6c6d6a49fc756a3493..24d320833f2d164b2fea0661a3dd4b554e623f1b 100644 (file)
@@ -40,6 +40,10 @@ static char *mount_resolve_src(const char *orig_str)
        char *mount_path;
        char *src;
        char *buf = strdup(orig_str);
+       if (!buf) {
+               fprintf(stderr, "%s: failed to allocate memory\n", __func__);
+               return NULL;
+       }
 
        mount_path = strstr(buf, ":/");
        if (!mount_path) {