Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934027AbcJRIyK (ORCPT ); Tue, 18 Oct 2016 04:54:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54452 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933538AbcJRIxn (ORCPT ); Tue, 18 Oct 2016 04:53:43 -0400 Date: Tue, 18 Oct 2016 10:53:28 +0200 (CEST) From: Sebastian Ott X-X-Sender: sebott@schleppi To: Martin Schwidefsky cc: Arnd Bergmann , Heiko Carstens , Linus Torvalds , linux-kernel@vger.kernel.org, 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: <20161018084855.1a100670@mschwide> References: <20161017220342.1627073-1-arnd@arndb.de> <20161017221650.1902729-6-arnd@arndb.de> <20161018084855.1a100670@mschwide> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) Organization: =?ISO-8859-15?Q?=22IBM_Deutschland_Research_&_Development_GmbH_=2F_Vorsitzende_des_Aufsichtsrats=3A_Martina_Koederitz_Gesch=E4ftsf=FChrung=3A_Dirk_Wittkopp_Sitz_der_Gesellschaft=3A_B=F6blingen_=2F_Registergericht?= =?ISO-8859-15?Q?=3A_Amtsgericht_Stuttgart=2C_HRB_243294=22?= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101808-0036-0000-0000-0000024655D4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101808-0037-0000-0000-000012E5BF55 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-18_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610180150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1769 Lines: 46 On Tue, 18 Oct 2016, Martin Schwidefsky wrote: > 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. 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 Regards, Sebastian