From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761362AbcIWQ57 (ORCPT ); Fri, 23 Sep 2016 12:57:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39259 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761117AbcIWQ55 (ORCPT ); Fri, 23 Sep 2016 12:57:57 -0400 Date: Fri, 23 Sep 2016 18:58:02 +0200 From: Greg Kroah-Hartman To: Colin King Cc: Vaibhav Agarwal , Johan Hovold , Alex Elder , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] greybus: audio: ensure module is set to avoid crash on dev_err message Message-ID: <20160923165802.GA7575@kroah.com> References: <20160923102540.18261-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160923102540.18261-1-colin.king@canonical.com> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 23, 2016 at 11:25:40AM +0100, Colin King wrote: > From: Colin Ian King > > Currently, if info is null, the dev_err message is dereferencing an > uninitialized module pointer. Instead, initialize module before the > dev_err call to fix this issue. > > Found using static analysis with cppcheck: > [drivers/staging/greybus/audio_topology.c:175]: (error) > Uninitialized variable: module > > Signed-off-by: Colin Ian King > --- > drivers/staging/greybus/audio_topology.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c > index 5eef536..c43a959 100644 > --- a/drivers/staging/greybus/audio_topology.c > +++ b/drivers/staging/greybus/audio_topology.c > @@ -171,6 +171,9 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, > data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; > info = (struct gb_audio_ctl_elem_info *)data->info; > > + module = find_gb_module(gbcodec, kcontrol->id.name); > + if (!module) > + return -EINVAL; How do you know you can get a module at this point in time, you haven't looked at the type of info to know that? I agree that there is an issue here, but I don't think this is the correct fix. Vaibhav?