extcon: cros-ec: Fix a potential NULL pointer dereference
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 7 Aug 2017 06:30:33 +0000 (08:30 +0200)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 7 Aug 2017 06:34:20 +0000 (15:34 +0900)
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>
drivers/extcon/extcon-usbc-cros-ec.c

index e759ed4..598956f 100644 (file)
@@ -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;