Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2317935pxu; Mon, 7 Dec 2020 03:34:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8Ygnj//e9fGyDHtZFfjKZqN/DYrM0/D8VxUe7aF5Iqvy66bRyNLyzXjo+8s3xesyWThmQ X-Received: by 2002:a50:fe0e:: with SMTP id f14mr19924804edt.159.1607340856899; Mon, 07 Dec 2020 03:34:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607340856; cv=none; d=google.com; s=arc-20160816; b=m154y0ECiof0F8QcBmTuID/EBjhJ4oHUDF32n7ZUY1navrDKjOH+rCUVy7Q0v99kc1 1cGHJVbqcZ5QqVHYbmbiHCuHx64R/A7wxMBCkxID+LOOWEWpRoPji8v4Bht2KPmjbr3h 64Sp/5Io0aPE/Dp4NuBlWJC+1rUiYakBih3G7cNwX1CdCX8vs7ga1yNkM7U2lwW854jp UITZprENlF20w+1uCI59E/HBY6vcMpYSbEyozSs2EfwqNbg9y49h8sj4pobmFL+P2kzb z7T/kc6spEgbmIfTiFrsLUnHH7v0iIRxLyUSctVF70sqBnVSrUqYX5goQZzOufg15llS n2qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from :dkim-signature:date; bh=ky3rlenTBedi4vAskTA5OI1S7dBDUFMzNNEjh1EJedc=; b=t8oyrfYLNXg5wKHOhprqM9Z4KaLEAq8/7d/+JdEblmwXJZW8fn+UUI5WpQDd1lvYGM S3m4COweSZxZq4/B92guoY5CoF4Sl8wK4hssekyV8AgxJDBYVr/xYZNNNe7hgqAB3zhs e5OdkROF6fAXjILIkWKPXkg9QrPj/YgUY9U/QIq9gcTtQRb6nkhs+eH+pSKrmb9MmETA FzMR1ipnGnLZ9VcygVEQ8jefJw5ASidTVrix9CFuOC8L+YXR3dXTOvK4M5xo9dxA+mEk Grt7pVKZdMn1SGxugzpLkOYrHjiiM+XCsWCqdkWAP7oJyEFuvNVJV+hN7PfmmTOALWUn wF7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AUlQ9xfa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si125240ejz.97.2020.12.07.03.33.53; Mon, 07 Dec 2020 03:34:16 -0800 (PST) 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=k20201202 header.b=AUlQ9xfa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgLGLaa (ORCPT + 99 others); Mon, 7 Dec 2020 06:30:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:53166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbgLGLa3 (ORCPT ); Mon, 7 Dec 2020 06:30:29 -0500 Date: Mon, 7 Dec 2020 11:29:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607340588; bh=PevOltpfSoa2VOQzzFcjWvvt+OU00vpXvLK5/D5qUXs=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=AUlQ9xfaq8dqQacDDAfA5Uncdfa9Y/1YFXLxQOPDFvSbZFX9TYSD2L2X9hVQRznoc WrRiS/8fM+PI2qboUZ0dwY88Lhl55Skm+GRDg0J9D0ydxQQisAApZPp0Y0l96gXQ3R ayrNFU+nY8ztzdSjEz1ApPGkb+e1F3jyRnfk0b9dD6NWb4+k1jRewsO/gtXQou2MqL Sp4EMQH/mXCnnNjFg25z7RV7DfLfCIyefjNGXzYp+dbZv8T1B8uS84D3rWFaijwbp/ Q4LohxUXYQj7pEEyOxZVtIswB8p3pU41/HlQ19FzTIFAhAZo285PXqh5A0bjpiVrw6 IYvTNP0Rhmfbw== From: Will Deacon To: Tian Tao Cc: robin.murphy@arm.com, joro@8bytes.org, jean-philippe@linaro.org, Jonathan.Cameron@huawei.com, song.bao.hua@hisilicon.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/arm-smmu-v3: Fix not checking return value about devm_add_action Message-ID: <20201207112943.GC4379@willie-the-truck> References: <1607340209-51539-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1607340209-51539-1-git-send-email-tiantao6@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 07, 2020 at 07:23:29PM +0800, Tian Tao wrote: > Use devm_add_action_or_reset to avoid the situation where the release > function is not called when devm_add_action returns an error. > > Signed-off-by: Tian Tao > > v2: > check the return value about evm_add_action_or_reset() > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 2ddf5ec..76c28e7 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2680,7 +2680,8 @@ static int arm_smmu_cmdq_init(struct arm_smmu_device *smmu) > ret = -ENOMEM; > } else { > cmdq->valid_map = bitmap; > - devm_add_action(smmu->dev, arm_smmu_cmdq_free_bitmap, bitmap); > + ret = devm_add_action_or_reset(smmu->dev, > + arm_smmu_cmdq_free_bitmap, bitmap); > } > > return ret; > @@ -2938,7 +2939,7 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) > } > > /* Add callback to free MSIs on teardown */ > - devm_add_action(dev, arm_smmu_free_msis, dev); > + devm_add_action_or_reset(dev, arm_smmu_free_msis, dev); Hmm, but you don't propagate the error here so couldn't this lead to a use-after-free? Will