Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705121

[PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Newsgroups linux.kernel
Subject [PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference
Date Mon, 07 Aug 2017 08:40:01 +0200
Message-ID <ubJRL-4Fq-9@gated-at.bofh.it> (permalink)
X-Original-To myungjoo.ham@samsung.com, cw00.choi@samsung.com
X-Me-Helo localhost.localdomain
X-Me-Auth Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI=
X-Me-Date Mon, 07 Aug 2017 08:30:37 +0200
X-Me-IP 90.21.163.120
X-Mailer git-send-email 2.11.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 24
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>
X-Original-Date Mon, 7 Aug 2017 08:30:33 +0200
X-Original-Message-ID <20170807063033.8063-1-christophe.jaillet@wanadoo.fr>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1705121

Show key headers only | View raw


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>
---
 drivers/extcon/extcon-usbc-cros-ec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/extcon/extcon-usbc-cros-ec.c b/drivers/extcon/extcon-usbc-cros-ec.c
index e759ed477735..598956f1dcae 100644
--- a/drivers/extcon/extcon-usbc-cros-ec.c
+++ b/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;
-- 
2.11.0

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-08-07 08:40 +0200
  Re: [PATCH] extcon: cros-ec: Fix a potential NULL pointer  dereference Chanwoo Choi <cw00.choi@samsung.com> - 2017-08-07 08:50 +0200

csiph-web