Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2663551pxa; Mon, 17 Aug 2020 15:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjFlLksh8q4EV2sWqh7xKdgI9NOb8WiQ0ZHSfdOcFnOtRKwCisMAs8EMoPZrbCxAFeuzR0 X-Received: by 2002:a50:bae6:: with SMTP id x93mr16927419ede.79.1597704948149; Mon, 17 Aug 2020 15:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704948; cv=none; d=google.com; s=arc-20160816; b=t1zPZlyV2f2rzjON8B8FojpyZehF6dUAfIMcDQX7VT7oRtSgdFdmMhX4j4HyJ9jHhA rh4PCbNPiaQ93ekpC/1wkt4kmAngrG0A+LmenTcqysVF/qZyD2QSFg7W8vWNuTLPEVEp AhzD2gQH5GcJk6YNUi7Hj/oBxvgIcptaT3AvA5tSykPaeoa06Kji2onUS4USBpA1Z2Ev uyn3q1Pxm/F87d7HKFmWJDHl9ONgienA1dqo//MpWoC4bDoMK9POjT8cjBcWKiddLQIN 8WuLewEJg8osMtQ2zRr/4+reaNNcFbtJrEHnAvSC8QbQTucuzBGj+Z7KezpE6HK/PxHz xmaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0lC0Ecwm2rFDQQ70UpHdtv6LvAm0UyFof+IOXSbb4Ks=; b=ukykQ4DSIn1HHOdYkOypWPE8HRMahaiFxqvdAiSR2OGlUu2h1AAm8EwhfC+MCK3wMR IvGZ90ygjcHo0C8b/6Yrp7Xd8/O7KGjpP7ypUw4ZWTjB7t+iR9WU9L6gJXJnVyv6N5qc Q7etF0E2PAnM4YDalDUKF9WCFi5k5moFUP7zQhZ4M6Sin4ec/DAgnjMQEbYo+UKdi2WI WalHwjX/4m8F4Ssq+QIKeDHMUmrTrvSiSsxuYBYsNhm80a+paD3AdSvusP5334W/ZAEL 3vyPG21Us0VftAdf/Rc+1W0H2AN3fiKqRSeh1e1igieLKnUDaExwZWUkXBJIIVQtS/1i iw1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tiq3mhzV; 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 q1si11879764edn.222.2020.08.17.15.55.25; Mon, 17 Aug 2020 15:55:48 -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=tiq3mhzV; 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 S2404269AbgHQTl2 (ORCPT + 99 others); Mon, 17 Aug 2020 15:41:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:58306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729709AbgHQPZO (ORCPT ); Mon, 17 Aug 2020 11:25:14 -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 D2DED22D6F; Mon, 17 Aug 2020 15:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677909; bh=0hpCvABZStLplECItoq4E4rTIl3EAyzd0ZRKA+1fl1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tiq3mhzV9vygI1uMRelv32L51fOfkUa5XcMjFNyjU9UhoyuQn1BpTQ5Yl0JktZa0e 6EMP6uXbdvZcarT8qBTs4BXcHW5Cv+Fb3GFN7SFXRt/7ch8wDKaMSqaAd8+2Cy94Uj JBVLATH3MFJCdNTkcWiKGDntZt63nryX1V+aXw7g= 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.8 122/464] iwlegacy: Check the return value of pcie_capability_read_*() Date: Mon, 17 Aug 2020 17:11:15 +0200 Message-Id: <20200817143839.656558576@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.25.1