linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Henrik Rydberg <rydberg@euromail.se>,
	Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] touchscreen/bu21013_ts: null dereference in error handling
Date: Wed, 27 Oct 2010 12:08:22 +0200	[thread overview]
Message-ID: <20101027100822.GF6062@bicker> (raw)

If kzalloc() returned NULL then it would lead to a NULL deref after the
goto.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index ccde586..8f120b1 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -446,11 +446,14 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	}
 
 	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
+	if (!bu21013_data)
+		return -ENOMEM;
+
 	in_dev = input_allocate_device();
-	if (!bu21013_data || !in_dev) {
+	if (!in_dev) {
 		dev_err(&client->dev, "device memory alloc failed\n");
 		error = -ENOMEM;
-		goto err_free_mem;
+		goto err_free;
 	}
 
 	bu21013_data->in_dev = in_dev;
@@ -515,6 +518,7 @@ err_cs_disable:
 	pdata->cs_dis(pdata->cs_pin);
 err_free_mem:
 	input_free_device(bu21013_data->in_dev);
+err_free:
 	kfree(bu21013_data);
 
 	return error;

             reply	other threads:[~2010-10-27 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 10:08 Dan Carpenter [this message]
2010-10-27 15:46 ` [patch] touchscreen/bu21013_ts: null dereference in error handling Dmitry Torokhov
2010-10-27 20:26   ` [patch v2] " Dan Carpenter

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=20101027100822.GF6062@bicker \
    --to=error27@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-input@vger.kernel.org \
    --cc=naveen.gaddipati@stericsson.com \
    --cc=rydberg@euromail.se \
    /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;
as well as URLs for NNTP newsgroup(s).