Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1159148imm; Wed, 1 Aug 2018 11:09:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdF8oZm5V1LZvlVzIjoV0tjbndvdR3KvYi6KCNY9TUHBcQqP0uBnHkxPBuosmk8BDNYqHHK X-Received: by 2002:a17:902:1025:: with SMTP id b34-v6mr20166369pla.291.1533146970160; Wed, 01 Aug 2018 11:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146970; cv=none; d=google.com; s=arc-20160816; b=p5+SywttIkyDjj8K26a0A9T6FWI4qpS/+kK9LTFeF4PoeyYo7wuAnqyMIb7NeQXzMn uIegSB1UiMcDqmMOLdh2DGACWCZVt8mHoxSJw506TgKyUtI3BNVj0X913X8lKMPh5Kto kgBO39KIqRR2ps0Gkxu1dEG1+2TNAaK6OMx5v9VA3LTSlqlOoN9bxzlds1L8Porj24xg RPnndLPd1alYfZ3WOE8ub3KpNZ5sEJOF0AcuP7Boahjr7SeGHFVK4uS0IYqUaY/E/NMD Tberts/EGv4NXmZO2oAe1KpEWMF9qrALdT6swDDnwDn5AFH4ZSCX+sPRVWlMn6w12WPk L4Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=eKyfE+tvCDoasardY1ZmvFNQuZNjpb2nwVeOxpCn2DU=; b=ijP+NvxNdsqbMdS6RjH3YoN5Ixl+1UCG6sIymbQMnTTpCXfvmxHbrhIe4sEOKo5pUV h2fBgutKAJegfeXOJhees+HLZvPp4FjAYP1HhGtNtk8jImtaVnlc4mooqcdKcu9tmL+/ wsgOIGMB/FrmCL68hCh0FIKHcW69Vhogai64W98VL9sixchA13cB3GM9MKQCW8IOZnzU d1saw9wO5jUnVvo+zwAR4ZWmHNrEovl6TZZh6inX3+xlkQmBKpNPTxLcyBcZxJouXVwY i+6YCU+1qx+ckcbyXKskE88XPnIwMNXMRbfcM9oyVOYSv6/paaSxfYTYSwbcg/JlHn2v zQYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16-v6si16174006pgc.82.2018.08.01.11.09.15; Wed, 01 Aug 2018 11:09:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732275AbeHATzV (ORCPT + 99 others); Wed, 1 Aug 2018 15:55:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731429AbeHATzS (ORCPT ); Wed, 1 Aug 2018 15:55:18 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1B2BFCBA; Wed, 1 Aug 2018 18:08:22 +0000 (UTC) Date: Wed, 1 Aug 2018 20:08:07 +0200 From: Greg KH To: Ivan Bornyakov Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, benchan@chromium.org, jnjoseph@google.com, rspringer@google.com Subject: Re: [PATCH] staging: gasket: sysfs: fix potential null dereference Message-ID: <20180801180807.GA31510@kroah.com> References: <20180731152320.11575-1-brnkv.i1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180731152320.11575-1-brnkv.i1@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 31, 2018 at 06:23:20PM +0300, Ivan Bornyakov wrote: > Add handling of possible allocation failure. > > Reported by smatch: > > drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null dereference 'files_to_remove'. (kcalloc returns null) > > Signed-off-by: Ivan Bornyakov > --- > drivers/staging/gasket/gasket_sysfs.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c > index ef4eca02afa6..682e5c21f203 100644 > --- a/drivers/staging/gasket/gasket_sysfs.c > +++ b/drivers/staging/gasket/gasket_sysfs.c > @@ -101,6 +101,12 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) > files_to_remove = kcalloc(num_files_to_remove, > sizeof(*files_to_remove), > GFP_KERNEL); > + if (!files_to_remove) { > + pr_err("%s: can't allocate memory\n", __func__); kcalloc failing will print something, no need to do it again here. thanks, greg k-h