Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4660286iob; Sun, 8 May 2022 20:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwncrMJjsuqpGaiqDMTRDonrwh+TvaTQr4BIWWeGUe3fXh09Gj18TqC3BQoGFTE4+tTKRVO X-Received: by 2002:a17:90b:4b42:b0:1dc:15f8:821b with SMTP id mi2-20020a17090b4b4200b001dc15f8821bmr24721631pjb.131.1652068785895; Sun, 08 May 2022 20:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652068785; cv=none; d=google.com; s=arc-20160816; b=WddHc1GNvsdEouWm1A0tUiWDqhCXkU3slG70UpPCzY/VazITvmsTpVqsGxhHlf2iA1 cEn0xu6kztIltz4wgBJfpyyg/IQJ21FSyJNDFjuyiaFncVsSrLEKi52pIV6V0bvBSh/r JuGwQX/805/kWRaLqHTyFGajaoljOtqx17shDt2pApk4ozDe4B5b5QVNvP3aCu4NJRAb a0RiU/Gh5GDUA1jEPQcwdO9T0+wLQRgwtQg/KAwycN7RrxbB8t/DXb67ff9gKqvMUjkD wQpinYqAhzU/zDNWZIdWpPquxAisrRUkdrwzn5D36vzqCYqqyTAXAzr/IlkvgwvcaLjy xrQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=I/+HvqGS+ovhwpFMmN1tKOy1lQ8plZViKNYQyJZMtus=; b=Cz9CIAY7tVbA22ken+4uJQBqapAf5OpvMVOrk9TESzORFmoSR3MFDK9uEtygQFeH9G rIHiHopvGr4oMWIvNQf5gy+R/RhuQYNjbqnkOMYrJynkftFLNU5NPg5/syvZG34gCAvV i+86UwCBzWYHGhk2FQzvWgzuyMGbXgVZ5gQ0EEhhPvUxxDfD9/ZW5OK7sWmTkWvTk+iI 7vMcTJhOOyleVp5MhHYq60UYA1RnX8xs6JUnlYeItq2J2EFyQH05JpPwIBV1CJQ6PMwu Qi+zZsIDnwogrQWhxLVxcnf2C7mXGKxlo00Bkvk8umLfwpe2zXg6GvuEFXQZkuJ/XXLG k36A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nl13-20020a17090b384d00b001d9fdd8c661si16350480pjb.181.2022.05.08.20.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C73A10237A; Sun, 8 May 2022 20:58:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347165AbiEDIzr (ORCPT + 99 others); Wed, 4 May 2022 04:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346896AbiEDIxx (ORCPT ); Wed, 4 May 2022 04:53:53 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD17025EBB; Wed, 4 May 2022 01:49:38 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 5A61167B; Wed, 4 May 2022 10:49:37 +0200 (CEST) Date: Wed, 4 May 2022 10:49:36 +0200 From: Joerg Roedel To: Xiaomeng Tong Cc: agross@kernel.org, bjorn.andersson@linaro.org, will@kernel.org, sricharan@codeaurora.org, linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] iommu: fix an incorrect NULL check on list iterator Message-ID: References: <20220501132823.12714-1-xiam0nd.tong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220501132823.12714-1-xiam0nd.tong@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 01, 2022 at 09:28:23PM +0800, Xiaomeng Tong wrote: > The bug is here: > if (!iommu || iommu->dev->of_node != spec->np) { > > The list iterator value 'iommu' will *always* be set and non-NULL by > list_for_each_entry(), so it is incorrect to assume that the iterator > value will be NULL if the list is empty or no element is found (in fact, > it will point to a invalid structure object containing HEAD). > > To fix the bug, use a new value 'iter' as the list iterator, while use > the old value 'iommu' as a dedicated variable to point to the found one, > and remove the unneeded check for 'iommu->dev->of_node != spec->np' > outside the loop. > > Cc: stable@vger.kernel.org > Fixes: f78ebca8ff3d6 ("iommu/msm: Add support for generic master bindings") > Signed-off-by: Xiaomeng Tong > --- > changes since v1: > - add a new iter variable (suggested by Joerg Roedel) This is now applied. I had to manually apply it because the patch was malformed at line 36 and git-am complained. Regards, Joerg