From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754083AbbELVCO (ORCPT ); Tue, 12 May 2015 17:02:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60835 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbbELVCM (ORCPT ); Tue, 12 May 2015 17:02:12 -0400 Date: Tue, 12 May 2015 14:02:11 -0700 From: Greg Kroah-Hartman To: Colin King Cc: Gigi Joseph , Eyal Reizer , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ti-st: handle null allocation return correctly. Message-ID: <20150512210211.GB10039@kroah.com> References: <1431454983-7800-1-git-send-email-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431454983-7800-1-git-send-email-colin.king@canonical.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2015 at 07:23:03PM +0100, Colin King wrote: > From: Colin Ian King > > 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 > --- > 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"); Care to remove this as well? It's not needed. thanks, greg k-h