Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp71025pxb; Mon, 1 Feb 2021 22:44:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwx2KJTzuArfUADg3VwqAigKAWZYZqLVLnf76aaXwCMq6keondgeu3BwT1COVfv3bFgIldA X-Received: by 2002:a17:906:1685:: with SMTP id s5mr4571326ejd.23.1612248265766; Mon, 01 Feb 2021 22:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612248265; cv=none; d=google.com; s=arc-20160816; b=RJt6sU+BjTaFWl/UlYmQhGDKGeVKes+T7tIBdcF7IDIcqRp2E9hM6zyudRvrsnRJkK ZGIiLmrMPo8FKLb2cPwhtzlo/Er/gkDL8768f6FigbNVd1hh2lYE5hWGFAuY3BAwfZkv +PU0TwSQRNG5xTBbe0M+vLo4MV2hVC/dfMpQ8GAsY+kA7/dXFOQkOvxsZ1AoFjw0N3/R DuQzh5qRwZTBllUwYBdQuB7HSS4T9YObZEqC9uYlraqBMHxoeWaoII+qRaL20OtfmZLO b3pbZkobCG68X8MvAfjmhkv/LvEgeBV9NGIhTMzBwTOIwsL/A2WCzM2vSDlR5MIsLzgY XopA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=RK5xKtrJLdWQ/gUfaUpmN+li3I540xSOX0vkQm3D8R0=; b=NPvis3GAvzetiAkUv3QHMzpEa1a4b5Bo9VxnJRpLyfSda8TzRshNcOh4bNWo73Q/uc /SKClb8akkFvbtQmtpoa8EDKEjC6vpxIsXZR4hA2G7avxxVDqZbzQFYU79XyAwKzcFv5 ZCvku8VwytnjnTeG15AnmmFe/YoAju5HBconWCVW9IWXZZMi8q7VrtVS/BTHX2WFwZwc O8wa2ZIX6MnGALtB0ts25hMmHKHAdU/k93LJ9GhvewkAxt/dvn7qd/UN1eB2ZUNAOPh0 W3o784Pkdp1RgXC+l+C7l6k7qdz8JRlMu7oHAmaSqBlgsXe7ZlHQolWdor9sqB7oo0Fo 6h8g== 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 r13si5339533ejz.437.2021.02.01.22.44.00; Mon, 01 Feb 2021 22:44:25 -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 S231951AbhBBGku (ORCPT + 99 others); Tue, 2 Feb 2021 01:40:50 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11669 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhBBGks (ORCPT ); Tue, 2 Feb 2021 01:40:48 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DVFWK6sbBzlFB2; Tue, 2 Feb 2021 14:38:21 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Tue, 2 Feb 2021 14:39:54 +0800 Subject: Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure To: Jean-Philippe Brucker , Eric Auger References: <20201118112151.25412-1-eric.auger@redhat.com> <20201118112151.25412-4-eric.auger@redhat.com> CC: , , , , , , , , , , , , , , From: Keqian Zhu Message-ID: Date: Tue, 2 Feb 2021 14:39:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jean, On 2021/2/1 23:15, Jean-Philippe Brucker wrote: > On Mon, Feb 01, 2021 at 08:26:41PM +0800, Keqian Zhu wrote: >>> +static int arm_smmu_insert_master(struct arm_smmu_device *smmu, >>> + struct arm_smmu_master *master) >>> +{ >>> + int i; >>> + int ret = 0; >>> + struct arm_smmu_stream *new_stream, *cur_stream; >>> + struct rb_node **new_node, *parent_node = NULL; >>> + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(master->dev); >>> + >>> + master->streams = kcalloc(fwspec->num_ids, >>> + sizeof(struct arm_smmu_stream), GFP_KERNEL); >>> + if (!master->streams) >>> + return -ENOMEM; >>> + master->num_streams = fwspec->num_ids; >> This is not roll-backed when fail. > > No need, the caller frees master OK. > >>> + >>> + mutex_lock(&smmu->streams_mutex); >>> + for (i = 0; i < fwspec->num_ids && !ret; i++) { >> Check ret at here, makes it hard to decide the start index of rollback. >> >> If we fail at here, then start index is (i-2). >> If we fail in the loop, then start index is (i-1). >> > [...] >>> + if (ret) { >>> + for (; i > 0; i--) >> should be (i >= 0)? >> And the start index seems not correct. > > Indeed, this whole bit is wrong. I'll fix it while resending the IOPF > series. > > Thanks, > Jean OK, I am glad it helps. Thanks, Keqian