Linux Input/HID development
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Böszörményi Zoltán" <zboszormenyi@sicom.com>,
	linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] Input: egalax: potential NULL dereference on error
Date: Sat, 19 Dec 2015 12:04:56 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.02.1512191204430.2055@localhost6.localdomain6> (raw)
In-Reply-To: <20151219105824.GA3749@mwanda>

On Sat, 19 Dec 2015, Dan Carpenter wrote:

> We didn't check input_allocate_device() for failures so it could lead to
> a NULL deref.

The patch does several other things...

julia

> 
> Fixes: 6b0f8f9c52ef ('Input: add eGalaxTouch serial touchscreen driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/input/touchscreen/egalax_ts_serial.c b/drivers/input/touchscreen/egalax_ts_serial.c
> index a078c1c..8becd26 100644
> --- a/drivers/input/touchscreen/egalax_ts_serial.c
> +++ b/drivers/input/touchscreen/egalax_ts_serial.c
> @@ -104,10 +104,13 @@ static int egalax_connect(struct serio *serio, struct serio_driver *drv)
>  	int error;
>  
>  	egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL);
> +	if (!egalax)
> +		return -ENOMEM;
> +
>  	input_dev = input_allocate_device();
> -	if (!egalax) {
> +	if (!input_dev) {
>  		error = -ENOMEM;
> -		goto err_free_mem;
> +		goto err_free_egalax;
>  	}
>  
>  	egalax->serio = serio;
> @@ -145,8 +148,8 @@ err_close_serio:
>  	serio_close(serio);
>  err_reset_drvdata:
>  	serio_set_drvdata(serio, NULL);
> -err_free_mem:
>  	input_free_device(input_dev);
> +err_free_egalax:
>  	kfree(egalax);
>  	return error;
>  }
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2015-12-19 11:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-19 10:58 [patch] Input: egalax: potential NULL dereference on error Dan Carpenter
2015-12-19 11:04 ` Julia Lawall [this message]
2015-12-19 20:04   ` Dan Carpenter
2015-12-19 17:21 ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1512191204430.2055@localhost6.localdomain6 \
    --to=julia.lawall@lip6.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=zboszormenyi@sicom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox