From patchwork Mon Aug 17 15:12:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC838C433E8 for ; Mon, 17 Aug 2020 19:05:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C489020758 for ; Mon, 17 Aug 2020 19:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597691130; bh=0hpCvABZStLplECItoq4E4rTIl3EAyzd0ZRKA+1fl1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=w0Yy9ksXg/btdu/HNOfy8iHbvq46f+2NY2WjH9JcqMU4RR6hpvO+vf5fUN1YwoZ2n pMwmM29FZGM8riSGjcboAScERFMkll1DU1c+QChKmdRjEAVVmFTJDCRQA78KqMnUpV c6ALF2wkpIB8bFIIhsMipX23NrxK55p/IafgYQPM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404092AbgHQTFG (ORCPT ); Mon, 17 Aug 2020 15:05:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:56596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730615AbgHQPpX (ORCPT ); Mon, 17 Aug 2020 11:45:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 BE6962075B; Mon, 17 Aug 2020 15:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679122; bh=0hpCvABZStLplECItoq4E4rTIl3EAyzd0ZRKA+1fl1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZoFbXhjTvqB7E5MjbuE9j9jt2uFpbH4QqKkmsP2R1ai82TRtT56zM5A7GjueVxKV SBp8QBE3uPDImORveA0StOdOqG1d2rY2PS4SFVrIBH3aHFnzHvXafDYToHKKEaidnh zlbP0gZSiug/7PeWjDYVB/a0UTQWo0x5tx5wsTAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Helgaas , Bolarinwa Olayemi Saheed , Kalle Valo , Sasha Levin Subject: [PATCH 5.7 104/393] iwlegacy: Check the return value of pcie_capability_read_*() Date: Mon, 17 Aug 2020 17:12:34 +0200 Message-Id: <20200817143824.658859548@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bolarinwa Olayemi Saheed [ Upstream commit 9018fd7f2a73e9b290f48a56b421558fa31e8b75 ] On failure pcie_capability_read_dword() sets it's last parameter, val to 0. However, with Patch 14/14, it is possible that val is set to ~0 on failure. This would introduce a bug because (x & x) == (~0 & x). This bug can be avoided without changing the function's behaviour if the return value of pcie_capability_read_dword is checked to confirm success. Check the return value of pcie_capability_read_dword() to ensure success. Suggested-by: Bjorn Helgaas Signed-off-by: Bolarinwa Olayemi Saheed Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200713175529.29715-3-refactormyself@gmail.com Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlegacy/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 348c17ce72f5c..f78e062df572a 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c @@ -4286,8 +4286,8 @@ il_apm_init(struct il_priv *il) * power savings, even without L1. */ if (il->cfg->set_l0s) { - pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); - if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { + ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); + if (!ret && (lctl & PCI_EXP_LNKCTL_ASPM_L1)) { /* L1-ASPM enabled; disable(!) L0S */ il_set_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);