mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ti-st: handle null allocation return correctly.
@ 2015-05-12 18:23 Colin King
  2015-05-12 21:02 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2015-05-12 18:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Gigi Joseph, Eyal Reizer; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-12 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 18:23 [PATCH] ti-st: handle null allocation return correctly Colin King
2015-05-12 21:02 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®