浏览代码

libceph: check kstrndup() return value

Should check result of kstrndup() in case of memory allocation failure.

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Chengguang Xu 8 年之前
父节点
当前提交
affff07739
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      net/ceph/ceph_common.c

+ 4 - 0
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);