Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp304335ybt; Tue, 7 Jul 2020 23:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyCHHKFxtIV47UvzNoO9P5T5/R9Ar6JfRvnHikvmJHM5dp6K2dRcNXPOwUGYfu/ZfjrVpO X-Received: by 2002:a17:906:95d9:: with SMTP id n25mr52005480ejy.437.1594191360380; Tue, 07 Jul 2020 23:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594191360; cv=none; d=google.com; s=arc-20160816; b=OQ2NAXhAFs3dPHKix/yrM4eroVx0ceicbsNxwcw0VyvkQVJLEv9hb2xhqbqRZbdiFo nXMnF0iN03K4ZHJEktEXEd/IdyRUmqpsCbd55iLsllm1meMS0JP6pE82ZHx9fIzH322W 8jb8LEdaFi7M6IT+ZO9Z/JRXud05Cm7EjCUFUjpXHKKUqT665q8wOnmQseWdwb1XFZeD oIwT5WzCkuH3O1s1dIgOjgcbUZqNzpnim3kOSkYGeQE0IDPeb5DjFjeH8E8hB0GSbzwJ mpdoUkRAJijSBeDiHp3smpjA2+fulwlazLW/XWQX0zT/nFB0EvOl1ZlmHvZ+f7kk5kVd IbvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QurWExNaRz1F8UG/TOexIzR0HIqQIWnDRkBK/dHWutw=; b=GTCJb4sDdZtPbYu6sweKi71JekpXTs+uVryAOknGpQVp786z9+PSMlOOh7X0PHhxUS 4eeKWUzDTt+ADhvOQljW8HgWfuuXZOaPoJBCqPz/T5z43mQcuVfcZtxk4gnbTZJzi7bG CAZa6zdfT0KVV6Y+grDNUgte1dtqUEwjymidJViW8reQ0EsKgyvtKLFc9xqXc4YMlVPN DRjvC4Ss/FvYpub0sQDiG9l1W2WnDtcPSQR4loZ8rw1Z1jj+lrq5fwcM94B934k1kI8V dxSY1BGbwhTW8QZSxumYZOTl3lbT7qIb2AiiNt4TTm/5pGgeeSQkt4HdZ1Fvc0suP7Ws YMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JZMg1ldP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l27si2369331ejg.613.2020.07.07.23.55.37; Tue, 07 Jul 2020 23:56:00 -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=JZMg1ldP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729667AbgGHGxf (ORCPT + 99 others); Wed, 8 Jul 2020 02:53:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:58106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729535AbgGHGxf (ORCPT ); Wed, 8 Jul 2020 02:53:35 -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 588792075B; Wed, 8 Jul 2020 06:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594191214; bh=g9ZlohxdxkjqpTSIdab6cJipB+jvPoyU/B+zybZjQug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JZMg1ldP1BXdzQiHMFkXu7aHxwTh64Vlhyckb9kaTg+GWWZzMNEut8mTQb8xJ+Y4D N6v87HtjIX4uGta6CD2crc/ju2GwnO835wcPKSVZaV67/yxL6pytZe0r1v5nIf5b3+ GDOWbSJYBqXmNDU02c6mR1J92fhfjTPWRzjOnU9Q= Date: Wed, 8 Jul 2020 08:53:30 +0200 From: Greg Kroah-Hartman To: Saheed Olayemi Bolarinwa Cc: helgaas@kernel.org, Arnd Bergmann , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/13] misc: rtsx: Check the return value of pcie_capability_read_*() Message-ID: <20200708065330.GA348669@kroah.com> References: <20200707220324.8425-1-refactormyself@gmail.com> <20200707220324.8425-3-refactormyself@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707220324.8425-3-refactormyself@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 12:03:13AM +0200, Saheed Olayemi Bolarinwa wrote: > From: Bolarinwa Olayemi Saheed > > On failure pcie_capability_read_dword() sets it's last parameter, val > to 0. In which case (val & PCI_EXP_DEVCTL2_LTR_EN) evaluates to 0. > However, with Patch 13/13, 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_word is checked to confirm success. > > Check the return value of pcie_capability_read_word() to ensure success. > > Suggested-by: Bjorn Helgaas > Signed-off-by: Bolarinwa Olayemi Saheed Acked-by: Greg Kroah-Hartman