[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <alpine.LFD.2.20.1610181034070.1706@schleppi>
Date: Tue, 18 Oct 2016 10:53:28 +0200 (CEST)
From: Sebastian Ott <sebott@...ux.vnet.ibm.com>
To: Martin Schwidefsky <schwidefsky@...ibm.com>
cc: Arnd Bergmann <arnd@...db.de>,
Heiko Carstens <heiko.carstens@...ibm.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Gerald Schaefer <gerald.schaefer@...ibm.com>,
Joerg Roedel <jroedel@...e.de>,
Christian Borntraeger <borntraeger@...ibm.com>,
linux-s390@...r.kernel.org
Subject: Re: [PATCH 25/28] s390: pci: don't print uninitialized data for
debugging
On Tue, 18 Oct 2016, Martin Schwidefsky wrote:
> On Tue, 18 Oct 2016 00:16:13 +0200
> Arnd Bergmann <arnd@...db.de> wrote:
>
> > gcc correctly warns about an incorrect use of the 'pa' variable
> > in case we pass an empty scatterlist to __s390_dma_map_sg:
> >
> > arch/s390/pci/pci_dma.c: In function '__s390_dma_map_sg':
> > arch/s390/pci/pci_dma.c:309:13: warning: 'pa' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > This adds a bogus initialization to the function to sanitize
> > the debug output. I would have preferred a solution without
> > the initialization, but I only got the report from the
> > kbuild bot after turning on the warning again, and didn't
> > manage to reproduce it myself.
> >
> > Signed-off-by: Arnd Bergmann <arnd@...db.de>
> > ---
> > arch/s390/pci/pci_dma.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
> > index 7350c8b..6b2f72f 100644
> > --- a/arch/s390/pci/pci_dma.c
> > +++ b/arch/s390/pci/pci_dma.c
> > @@ -423,7 +423,7 @@ static int __s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
> > dma_addr_t dma_addr_base, dma_addr;
> > int flags = ZPCI_PTE_VALID;
> > struct scatterlist *s;
> > - unsigned long pa;
> > + unsigned long pa = 0;
> > int ret;
> >
> > size = PAGE_ALIGN(size);
>
> The compiler is right. pa is set in the for-loop. If "dma_addr < dma_addr_base + size"
> is never true and __dma_purge_tlb() returns with an error, pa *is* uninitialized.
> The fix seems sensible to me.
Although that could only happen if map_sg is called with zero length sg
list entries I'm in favor getting rid of that warning.
Acked-by: Sebastian Ott <sebott@...ux.vnet.ibm.com>
Regards,
Sebastian
Powered by blists - more mailing lists