From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933821AbcCRP5j (ORCPT ); Fri, 18 Mar 2016 11:57:39 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:33447 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756758AbcCRP5h (ORCPT ); Fri, 18 Mar 2016 11:57:37 -0400 Date: Fri, 18 Mar 2016 16:57:32 +0100 From: Andrey Shvetsov To: Geert Uytterhoeven Cc: Christian Gromm , Greg KH , driverdevel , Linux Kernel Mailing List Subject: Re: staging: most: warning: =?utf-8?B?4oCY?= =?utf-8?B?bWJv4oCZ?= may be used uninitialized in this function Message-ID: <20160318155732.GB2555@arch.fritz.box> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 18, 2016 at 01:41:19PM +0100, Geert Uytterhoeven wrote: > On Fri, Mar 18, 2016 at 6:42 AM, Linux Kernel Mailing List > wrote: > > Web: https://git.kernel.org/torvalds/c/f45b0fba43f415f69982df743dfa9b5d1b57785e > > Commit: f45b0fba43f415f69982df743dfa9b5d1b57785e > > Parent: b3c9f3c56c41cbebe7804b48ba8e6e484509c2c0 > > Refname: refs/heads/master > > Author: Christian Gromm > > AuthorDate: Tue Dec 22 10:53:06 2015 +0100 > > Committer: Greg Kroah-Hartman > > CommitDate: Sun Feb 7 17:34:58 2016 -0800 > > > > staging: most: remove stacked_mbo > > > > This patch makes use of kfifo_peek and kfifo_skip, which renders the > > variable stacked_mbo useless. It is therefore removed. > > > > Signed-off-by: Christian Gromm > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/staging/most/aim-cdev/cdev.c | 16 +++------------- > > 1 file changed, 3 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c > > index d9c3f56..0ee2f08 100644 > > --- a/drivers/staging/most/aim-cdev/cdev.c > > +++ b/drivers/staging/most/aim-cdev/cdev.c > > > @@ -249,11 +246,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) > > struct aim_channel *c = filp->private_data; > > > > mutex_lock(&c->io_mutex); > > - if (c->stacked_mbo) { > > - mbo = c->stacked_mbo; > > - goto start_copy; > > - } > > - while ((!kfifo_out(&c->fifo, &mbo, 1)) && (c->dev)) { > > + while (c->dev && !kfifo_peek(&c->fifo, &mbo)) { > > drivers/staging/most/aim-cdev/cdev.c:241: warning: ‘mbo’ may be used > uninitialized in this function > > From looking at the code, it's not obvious to me if this is a false > positive or not. > Can it happen that mbo is not initialized fully, e.g. if less than sizeof(mbo) > bytes have been read from the kfifo? > mbo is not touched by the kfifo_peek in the case where (c->dev == NULL), but since we protect the c->dev by the io_mutex it remains NULL until the check after the while loop where we quit. Looks like the analyzer suspects that c->dev may be changed to a valid pointer before the second check. So, it is false positive, but it is worth to initialize the mbo with the NULL to get rid of the warning. regards andy