All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Gigi Joseph <gigi.joseph@gmail.com>, Eyal Reizer <eyalr@ti.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] ti-st: handle null allocation return correctly.
Date: Tue, 12 May 2015 19:23:03 +0100	[thread overview]
Message-ID: <1431454983-7800-1-git-send-email-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

static analysis with smatch picked up the following error:

get_platform_data() error: potential null dereference 'dt_pdata'.
  (kzalloc returns null)

ironically, the code already checks for a null kzalloc return and
emits an error message.  Fix by adding an error return of NULL rather
than continuing and tripping the null dereference.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/misc/ti-st/st_kim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 18e7a03..5a5265a 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -753,8 +753,10 @@ static struct ti_st_plat_data *get_platform_data(struct device *dev)
 
 	dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
 
-	if (!dt_pdata)
+	if (!dt_pdata) {
 		pr_err("Can't allocate device_tree platform data\n");
+		return NULL;
+	}
 
 	dt_property = of_get_property(np, "dev_name", &len);
 	if (dt_property)
-- 
2.1.4


             reply	other threads:[~2015-05-12 18:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 18:23 Colin King [this message]
2015-05-12 21:02 ` [PATCH] ti-st: handle null allocation return correctly Greg Kroah-Hartman

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=1431454983-7800-1-git-send-email-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=eyalr@ti.com \
    --cc=gigi.joseph@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.