Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2314530pxu; Mon, 7 Dec 2020 03:28:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzq8OEQQzh7sOubbIn+uyEcmZ3B8dDxGLqGSlZgwCHHFTqHvgPHcuPuzPN/AyB5gkQvqpSr X-Received: by 2002:aa7:dac5:: with SMTP id x5mr19840280eds.198.1607340482312; Mon, 07 Dec 2020 03:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607340482; cv=none; d=google.com; s=arc-20160816; b=sKjCN0ypUEklefgqvJo4EHdthX/BAwe8Xm5IEDaHDU5wmvKuQw7eUei96IQfwxGtbq H9lwplI/wdJkv5dyAk0hVSjFPnqUHux8taJA/NkeUC3fv3zWEGb1Nt3AnxwKNgVomGUA 8tCH3HAg4O+iVfM8jtaLvIPQPfP+tp4ZDffUzwhmxnTuv3dlDCchnEG7f+SZg/fOdDOA jWq9ANLjTiN4+9XZQdQZgQ0mg2UnRNhWHWuTw16GdJEFfLBqVNDePDEbyBv85I8fuygN VlsKkCH1w2VDk3tNt0SzIekuiV2IHmkkkQ1kKnbkVsI5xva6vGB/aYuQKutBCz1rNo19 KOTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=FJWPqIAcHDmb248v05O6ON2KKZgiLMoMSs2BUtoAXRA=; b=jWUkeM5odmtn3eyG42MKcw9CEsXVL/ySU6yTxsbSliKfto5nSPV4VlqFVgiEtyOrtr 4cGhTTMplmuu8W6cqg7AC3k10S+9LZ+6A0OtsO33bENvrVdxq9iNZcRiA/iaUUpD6u5r 97HOdJfLKjDmSNmHzt8c+oq5Jqjf91JqAPSjVQe1AinZNf298bm1Al+zfO/GPYH+VEDH L1C/8nIsA0MxDXyoztun+eFdJD+J88tuyjninnKthRfdhbZvI3AvxFnlLb/7SOqmFAQ8 Szmn2ajaNMj0dJTy+YnXG5xl/qiAcYmBLzuCOJkz4TH9JtS8NjfUMecTPTZQ/Avl0C0J MUUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 eb10si7918778edb.192.2020.12.07.03.27.39; Mon, 07 Dec 2020 03:28:02 -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; 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 S1726332AbgLGLYL (ORCPT + 99 others); Mon, 7 Dec 2020 06:24:11 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9112 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgLGLYL (ORCPT ); Mon, 7 Dec 2020 06:24:11 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CqLWm1h5RzM1Tb; Mon, 7 Dec 2020 19:22:44 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Dec 2020 19:23:15 +0800 From: Tian Tao To: , , , , , CC: , , Subject: [PATCH] iommu/arm-smmu-v3: Fix not checking return value about devm_add_action Date: Mon, 7 Dec 2020 19:23:29 +0800 Message-ID: <1607340209-51539-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) -- 2.7.4