From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FB4FC433E0 for ; Tue, 2 Feb 2021 06:41:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1691064EDD for ; Tue, 2 Feb 2021 06:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbhBBGku (ORCPT ); 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: kvm@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