Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3699795pxk; Tue, 29 Sep 2020 04:10:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygldRJzAGJCzMGH8GKUo7s8ZbaJBNGvjvCVNHZRBIoXuRs8lC7Sx+OM+7DVt+WUjzQfqfP X-Received: by 2002:a17:906:3b03:: with SMTP id g3mr3144628ejf.506.1601377802471; Tue, 29 Sep 2020 04:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601377802; cv=none; d=google.com; s=arc-20160816; b=LLfS3O/rC0K8z0/pXPONc9v1BjAibS4y5fIuHnitW/e9Wd3O3dyK5A+XV/a2rnDtKh VSiDpNNS7PGdZZ0yRUkYMfn7zkUG9HCBG8mZ1PNy9oDFQEuQWdK7I11tHpaR8ja/mzN9 nI/rVEHJ3bOr+GRfPhJfMyheeaPJfDBhDFy90/Lv4W7EK+YISMAL8hv40oC6P7JpYpx9 Q1km8+MIur4xhzObQW9Isauv/n+9bKUytBATZN40bMuDCkgpl972/dTFvqaaiuGL90nf QWW2XJ5b95odZSKNvZ4j5kguTtlqPLwxBMz+Xcgc3maYVtyxtgZ0iZmqAs4Y+R4oZ6o4 QyjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3pgpuz4uPJy7cFeK+LD6xrDaTbY6fU4WL/rllQzw538=; b=DYwQ+MHOREGCr0QBH6dUXZpoous+bOodjsgM5VPhE2UHVXDdmxgm7HLNdPE/nuWsl6 zuBPXHHzb2ktACgm5QgVjLNH4nCIIEHxn+YYqhhhNOf7B94f5PhjgOWltw9X+Mnx1imf V23bfwGxsoZUC1UAA5aLDz0tr84wnSSSJockphI2W910azdZI+zk3wHe4c/FTCmXcSKO +jo/T+MCl/Qx3rrrR0sWQPh/zlOOI4Bx2RoSCrP7TeY1K1wI+PruUdTEzDlG+C6skAM5 dRF06A3KvIwg3LVJ1gkv/Gbt8nXQCkSfnUqlRP44ZPAH4IwWUWG/PfyhUmIz/VILE7Pm jkdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2eDwT2F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si2509397ejg.435.2020.09.29.04.09.39; Tue, 29 Sep 2020 04:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2eDwT2F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728424AbgI2LGH (ORCPT + 99 others); Tue, 29 Sep 2020 07:06:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:42608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbgI2LGD (ORCPT ); Tue, 29 Sep 2020 07:06:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0C3A21D46; Tue, 29 Sep 2020 11:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377562; bh=/ALTlSTTomaL7eHD2FljyEB1C+r2rap3GCaH24L+beM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2eDwT2F77KwWcgqaP49GIKI0kx2yqz+20cCOvcSRNmY0aOjpHnBoKr0oBNxlj8hN PR/0vVI3+zlHRlT/3SQTsrOplwx0Pxy4byuRTfStPqb/w+uOP3kAZkwRWPE7g8OC11 KOQNBVyaxynxxQx71PWd0zYDFi2jhfw4bDI8Ud1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Takashi Iwai , Sasha Levin Subject: [PATCH 4.4 78/85] ALSA: asihpi: fix iounmap in error handler Date: Tue, 29 Sep 2020 13:00:45 +0200 Message-Id: <20200929105932.095294562@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105928.198942536@linuxfoundation.org> References: <20200929105928.198942536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix [ Upstream commit 472eb39103e885f302fd8fd6eff104fcf5503f1b ] clang static analysis flags this problem hpioctl.c:513:7: warning: Branch condition evaluates to a garbage value if (pci.ap_mem_base[idx]) { ^~~~~~~~~~~~~~~~~~~~ If there is a failure in the middle of the memory space loop, only some of the memory spaces need to be cleaned up. At the error handler, idx holds the number of successful memory spaces mapped. So rework the handler loop to use the old idx. There is a second problem, the memory space loop conditionally iomaps()/sets the mem_base so it is necessay to initize pci. Fixes: 719f82d3987a ("ALSA: Add support of AudioScience ASI boards") Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20200913165230.17166-1-trix@redhat.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/asihpi/hpioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 7a32abbe0cef8..4bdcb7443b1f5 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -346,7 +346,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, struct hpi_message hm; struct hpi_response hr; struct hpi_adapter adapter; - struct hpi_pci pci; + struct hpi_pci pci = { 0 }; memset(&adapter, 0, sizeof(adapter)); @@ -502,7 +502,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, return 0; err: - for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { + while (--idx >= 0) { if (pci.ap_mem_base[idx]) { iounmap(pci.ap_mem_base[idx]); pci.ap_mem_base[idx] = NULL; -- 2.25.1