From patchwork Mon Aug 17 15:14:40 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: 266209 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 CE5D6C433DF for ; Mon, 17 Aug 2020 18:25:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6C912075B for ; Mon, 17 Aug 2020 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597688741; bh=Dvl4wZjTh9kZL21GzFmX/cOdrfrYvQ6it6+kPYs6ALY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=VsrYLlLkRD8A42d/3457kPYB8x1VbzwRxYmWoE1tnFCGOnMJrhBLT7rgrR1fw/l1F nKB/anN0IKEcJySx2QmOXOrKf47HT5CQIvNnHm236jJ2N8/z2AjU57eAcAtUCi0I5c 6OhTMmLpx3ljXuessZWXDwTIycV0giVQ3nU4qyP4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731522AbgHQSZa (ORCPT ); Mon, 17 Aug 2020 14:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:50364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388225AbgHQQCu (ORCPT ); Mon, 17 Aug 2020 12:02:50 -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 E335020748; Mon, 17 Aug 2020 16:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680170; bh=Dvl4wZjTh9kZL21GzFmX/cOdrfrYvQ6it6+kPYs6ALY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ta+EWwlxBeMdljp1uIDpR+BcaZ7n6sWyk6VJ60hjfHq4zy0A6M23x/xbAUc+AIqgb BSy0PZUJY+3nJs/ZNolMd8v47VtzAPBK+KSlkOdZrVuzDv5Dt9YQZhbYJ9seDfdM4U 6V2Izxng+RILuwIJNbq48/riTt88jmMMG3eW4wuk= 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.4 079/270] iwlegacy: Check the return value of pcie_capability_read_*() Date: Mon, 17 Aug 2020 17:14:40 +0200 Message-Id: <20200817143759.700820288@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 746749f379964..1107b96a8a880 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);