From b737cc424850a5108898a065f9572804b2b0ce49 Mon Sep 17 00:00:00 2001 From: songweibin Date: Thu, 25 Jul 2019 19:05:33 +0800 Subject: [PATCH] src/mount: check before dereference buf CID 180671 (#1 of 1): Dereference null return value (NULL_RETURNS) Signed-off-by: songweibin --- src/mount/mount.ceph.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 1345e7f4512..24d320833f2 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -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) { -- 2.39.5