Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758456AbcJRGtF (ORCPT ); Tue, 18 Oct 2016 02:49:05 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47738 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758124AbcJRGtC (ORCPT ); Tue, 18 Oct 2016 02:49:02 -0400 Date: Tue, 18 Oct 2016 08:48:55 +0200 From: Martin Schwidefsky To: Arnd Bergmann Cc: Heiko Carstens , Linus Torvalds , linux-kernel@vger.kernel.org, Sebastian Ott , Gerald Schaefer , Joerg Roedel , Christian Borntraeger , linux-s390@vger.kernel.org Subject: Re: [PATCH 25/28] s390: pci: don't print uninitialized data for debugging In-Reply-To: <20161017221650.1902729-6-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> <20161017221650.1902729-6-arnd@arndb.de> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101806-0016-0000-0000-0000024D7840 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101806-0017-0000-0000-0000236FEE48 Message-Id: <20161018084855.1a100670@mschwide> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-18_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610180113 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1523 Lines: 43 On Tue, 18 Oct 2016 00:16:13 +0200 Arnd Bergmann 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 > --- > 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. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.