浏览代码

extcon: cros-ec: Fix a potential NULL pointer dereference

Return -ENOMEM in case of memory allocation failure. This avoids a NULL
pointer dereference.

Fixes: c69831666109 ("extcon: cros-ec: Add extcon-cros-ec driver to support display out")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Christophe JAILLET 8 年之前
父节点
当前提交
1cf76c4eeb
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/extcon/extcon-usbc-cros-ec.c

+ 2 - 0
drivers/extcon/extcon-usbc-cros-ec.c

@@ -68,6 +68,8 @@ static int cros_ec_pd_command(struct cros_ec_extcon_info *info,
 	int ret;
 
 	msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
 
 	msg->version = version;
 	msg->command = command;