From: Chengguang Xu Date: Fri, 26 Jan 2018 06:54:43 +0000 (+0800) Subject: libceph: check kstrndup() return value X-Git-Tag: v4.16-rc1~32^2~1 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=affff07739392920d3d2095212c72af220481b95;p=linux.git libceph: check kstrndup() return value Should check result of kstrndup() in case of memory allocation failure. Signed-off-by: Chengguang Xu Signed-off-by: Ilya Dryomov --- diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 5c036d2f401e..1e492ef2a33d 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -421,6 +421,10 @@ ceph_parse_options(char *options, const char *dev_name, opt->name = kstrndup(argstr[0].from, argstr[0].to-argstr[0].from, GFP_KERNEL); + if (!opt->name) { + err = -ENOMEM; + goto out; + } break; case Opt_secret: opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);