From mboxrd@z Thu Jan 1 00:00:00 1970 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, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 BCD30C433E7 for ; Mon, 13 Jul 2020 16:55:18 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 904262067D for ; Mon, 13 Jul 2020 16:55:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qmI/dKku" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 904262067D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5BED12474E; Mon, 13 Jul 2020 16:55:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4P-zfTXfjJDw; Mon, 13 Jul 2020 16:55:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 1522623735; Mon, 13 Jul 2020 16:55:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AEE8AC08A8; Mon, 13 Jul 2020 16:55:16 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2771FC0733 for ; Mon, 13 Jul 2020 16:55:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 16D2A8527D for ; Mon, 13 Jul 2020 16:55:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id isfuNLu23Gd9 for ; Mon, 13 Jul 2020 16:55:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 030B282441 for ; Mon, 13 Jul 2020 16:55:14 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id z17so14273577edr.9 for ; Mon, 13 Jul 2020 09:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=236yoLO9rvFi7kFEaDT+jdNhQShh5zAyQTJD1cMNwbc=; b=qmI/dKkuGKWs1uJ/X+ORo2j9ZYWZLY//kGgOrJqvN0aGQHXouo9YDB4nmjhqfGS5HE w7TNx7OdD/HGeRKuN/8SUJOm/BYKXqm/oPoQDqXcvJrWQQCyGA2M16n9RvjaO+kfo7Mg vPGH++wf3L1TXs1DHBmVvhPRFmAFDdsoJZz6BPqAbYRpQDk9aHt20GC2FxkITx2TVBCA /2Y2Iz0OfTDCHMcXstLS1S96GW8SIkIfj0gVI9DD0VKL3DMNUdWO27amm2BoqL3uFH94 RSyexOquu8pAfOIGi1x4GhBae9z3c/MauTBf+xMYA5e8tncOHKWz9HEGhtvQN9D/oJAv PCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=236yoLO9rvFi7kFEaDT+jdNhQShh5zAyQTJD1cMNwbc=; b=mXDlanjo1KOwSkAL8RaEw9rTRuWVER0epNFti4cB4O7HOTnR1J/KkqMttd/vCprri+ XSuTA4ni5TDBgGsAVScc+ztsttg4Z9N11+FXpi34+E1SD/5vUeGtTJIXmXilUlp9oiDG NK8JzcgJqfWeKRATTwGYIB4FO18Bm28XZlSKgRQmpGUsopaKgibNKILkQijQDmTjyC80 /+ZxyO+sBdXRc9QfKPnOx2jWcegxCVWbjnle9iC1q9eKbVKNPPqUTqzNI21ngdWyMv1+ ntvu3bhLCExxGv9Z9GXGcfMlimWGBXW4cPKA3QQH7o2wl15pR883e1d33tZLDWwWN4w+ OqhQ== X-Gm-Message-State: AOAM532AYqCO+SiWXWmxhjbVghJtVA5lspzLyrYgPTNJwGALvcbMiFU2 +kYGQTuHSXjx2jc48i3HcXNFghyC0LQAlQ== X-Google-Smtp-Source: ABdhPJzS8bGidfvYhEBX+Vxk3kFa37roPQ//u7I4H6NbrGfX2t/Lv7uDWvR+9xa8wn77M37ExBUJqw== X-Received: by 2002:a05:6402:b9b:: with SMTP id cf27mr368195edb.84.1594659312267; Mon, 13 Jul 2020 09:55:12 -0700 (PDT) Received: from net.saheed (54007186.dsl.pool.telekom.hu. [84.0.113.134]) by smtp.gmail.com with ESMTPSA id w3sm11838938edq.65.2020.07.13.09.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 09:55:11 -0700 (PDT) From: "Saheed O. Bolarinwa" To: skhan@linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, QCA ath9k Development , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Date: Mon, 13 Jul 2020 19:55:26 +0200 Message-Id: <20200713175529.29715-2-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200713175529.29715-1-refactormyself@gmail.com> References: <20200713175529.29715-1-refactormyself@gmail.com> Cc: Bolarinwa Olayemi Saheed , Kalle Valo Subject: [Linux-kernel-mentees] [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" From: Bolarinwa Olayemi Saheed 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 --- drivers/net/wireless/ath/ath9k/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index f3461b193c7a..cff9af3af38d 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c @@ -825,6 +825,7 @@ static void ath_pci_aspm_init(struct ath_common *common) struct pci_dev *pdev = to_pci_dev(sc->dev); struct pci_dev *parent; u16 aspm; + int ret; if (!ah->is_pciexpress) return; @@ -866,8 +867,8 @@ static void ath_pci_aspm_init(struct ath_common *common) if (AR_SREV_9462(ah)) pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix); - pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); - if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) { + ret = pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); + if (!ret && (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1))) { ah->aspm_enabled = true; /* Initialize PCIe PM and SERDES registers. */ ath9k_hw_configpcipowersave(ah, false); -- 2.18.2 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 A5424C43445 for ; Mon, 13 Jul 2020 16:55:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D16E2076D for ; Mon, 13 Jul 2020 16:55:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qmI/dKku" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729659AbgGMQzO (ORCPT ); Mon, 13 Jul 2020 12:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729969AbgGMQzN (ORCPT ); Mon, 13 Jul 2020 12:55:13 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CAE8C061755; Mon, 13 Jul 2020 09:55:13 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id by13so14266940edb.11; Mon, 13 Jul 2020 09:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=236yoLO9rvFi7kFEaDT+jdNhQShh5zAyQTJD1cMNwbc=; b=qmI/dKkuGKWs1uJ/X+ORo2j9ZYWZLY//kGgOrJqvN0aGQHXouo9YDB4nmjhqfGS5HE w7TNx7OdD/HGeRKuN/8SUJOm/BYKXqm/oPoQDqXcvJrWQQCyGA2M16n9RvjaO+kfo7Mg vPGH++wf3L1TXs1DHBmVvhPRFmAFDdsoJZz6BPqAbYRpQDk9aHt20GC2FxkITx2TVBCA /2Y2Iz0OfTDCHMcXstLS1S96GW8SIkIfj0gVI9DD0VKL3DMNUdWO27amm2BoqL3uFH94 RSyexOquu8pAfOIGi1x4GhBae9z3c/MauTBf+xMYA5e8tncOHKWz9HEGhtvQN9D/oJAv PCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=236yoLO9rvFi7kFEaDT+jdNhQShh5zAyQTJD1cMNwbc=; b=TxkC1ukwDOApE2S2zSNAlLVBssK1iMxDwsmR8n56YSVuuLmSR5EcJSVC5qJK+NIF3R udrW2SfNJLlvZrUkFThu496iGsyvyUBL4pOF542QNqj46Ct8/fstw3MzBRQqaZXH9B+9 EOUVDbHh9ggUJjuqhOgCXYPCYkgLqTlMUDEBsiXdjaU9jifaCQ3khQa84Ofa1c4Lfy30 hoyPSXHeBXm2DfSyatAWyXXpyhMhgPPcI3oEzhJ1Pb5wuashdAMFK95ttV6qr+P0kIWy qodRFTpgUZfhgVD4HAIasHW/N7pK93okn84ulTyRp7YeZtESnbvTjXgCjYuxhdE901gU wsUA== X-Gm-Message-State: AOAM533MSAyoWMqgYIsN5fi/seFiB4/Qsmv2p/oqhV6N3w/NX3gWXyRn y2Tg7Yf/xC3CDjOFhK9Ttws= X-Google-Smtp-Source: ABdhPJzS8bGidfvYhEBX+Vxk3kFa37roPQ//u7I4H6NbrGfX2t/Lv7uDWvR+9xa8wn77M37ExBUJqw== X-Received: by 2002:a05:6402:b9b:: with SMTP id cf27mr368195edb.84.1594659312267; Mon, 13 Jul 2020 09:55:12 -0700 (PDT) Received: from net.saheed (54007186.dsl.pool.telekom.hu. [84.0.113.134]) by smtp.gmail.com with ESMTPSA id w3sm11838938edq.65.2020.07.13.09.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 09:55:11 -0700 (PDT) From: "Saheed O. Bolarinwa" To: skhan@linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, QCA ath9k Development , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: Bolarinwa Olayemi Saheed , Kalle Valo Subject: [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() Date: Mon, 13 Jul 2020 19:55:26 +0200 Message-Id: <20200713175529.29715-2-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200713175529.29715-1-refactormyself@gmail.com> References: <20200713175529.29715-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Bolarinwa Olayemi Saheed 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 --- drivers/net/wireless/ath/ath9k/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index f3461b193c7a..cff9af3af38d 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c @@ -825,6 +825,7 @@ static void ath_pci_aspm_init(struct ath_common *common) struct pci_dev *pdev = to_pci_dev(sc->dev); struct pci_dev *parent; u16 aspm; + int ret; if (!ah->is_pciexpress) return; @@ -866,8 +867,8 @@ static void ath_pci_aspm_init(struct ath_common *common) if (AR_SREV_9462(ah)) pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix); - pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); - if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) { + ret = pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); + if (!ret && (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1))) { ah->aspm_enabled = true; /* Initialize PCIe PM and SERDES registers. */ ath9k_hw_configpcipowersave(ah, false); -- 2.18.2