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


Groups > linux.kernel > #1705121 > unrolled thread

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

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-08-07 08:40 +0200
Last post2017-08-07 08:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [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

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

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-08-07 08:40 +0200
Subject[PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference
Message-ID<ubJRL-4Fq-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1705129 — Re: [PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference

FromChanwoo Choi <cw00.choi@samsung.com>
Date2017-08-07 08:50 +0200
SubjectRe: [PATCH] extcon: cros-ec: Fix a potential NULL pointer dereference
Message-ID<ubK1t-4ID-13@gated-at.bofh.it>
In reply to#1705121
Hi,

On 2017년 08월 07일 15:30, Christophe JAILLET wrote:
> 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;
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web