Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5611216pxu; Wed, 23 Dec 2020 00:27:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJypKTmfjUlYlfOS5PNQuOYj4a0DqQfxow6KZLJYfb2ql8WuegeioOHRnyZDFpUbiMiqdKLX X-Received: by 2002:a17:906:b002:: with SMTP id v2mr23353514ejy.531.1608712065129; Wed, 23 Dec 2020 00:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608712065; cv=none; d=google.com; s=arc-20160816; b=vifSL6fixCdwZxnSuCSwORyqrkmNtm2b0IpSqdDdg9porZtTMpZJqoPlVGCXQvLPUu GaTLougZ6x539FfEEh8LmlCwWSg0nkjRb6Myp0kJXFaovugcuSWMtqAYFTW+9phY73ll Nklbw/HQK5ormoPZ+SJxPbRnqjxvAfqGeq7tSx/3fgLNJmgUG+5AzEnI1D/eti7BB5wr y2cTonaNhcb5J5FCvcDBQHH0KcNojQz2RFnRVOP5jDtT1UQHUTjamluoutoGCDumcEEo kJEZeGPBCv/0b9+EsX2usWoGIgZ2moXS5/HXmOZzz3DAxPDIa9rwYhpHmGU3AiXzoGeb VJVg== 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:dkim-signature; bh=WThy4tT62F3b3zf0PgQRiQWDvTgvmZESA9P7XUtvIQc=; b=HdyvobMTprxl316TQt38yD5qXeJaIRItLWA5s1XoHc9TfIOqA2yNL8AScclkkGt9OL AvJfZfcKEjlMaL+tL//1HAVKYVRqQx/xX3cBLtTw6urRjtkzCoeIdGEFX1ES1AAcQKg1 wLLjm8EgEcsIpC4OGI2ky8xJZ/OpLyRKJqX1UROHsOeBYnF5TlnwF6EAw3fI262gfXJ6 dcRN/Ug0SuPtsmzp8w1/EKicdtttxwzJTFksB2TCIYbIXTh1HpgLpuBuOZ8xQ1HptJOo vHAd7vMUnM0y8Yx24gfec/qMnfNe5k/oIBqY0qe/ChTF6e8H4I+8N4RDSCz++gKTCSR5 093g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="lm/gAASM"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id uz9si11629186ejb.386.2020.12.23.00.27.22; Wed, 23 Dec 2020 00:27:45 -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=@chromium.org header.s=google header.b="lm/gAASM"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728138AbgLWI0O (ORCPT + 99 others); Wed, 23 Dec 2020 03:26:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728062AbgLWI0O (ORCPT ); Wed, 23 Dec 2020 03:26:14 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0958C0613D3 for ; Wed, 23 Dec 2020 00:25:33 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id g15so5252987pgu.9 for ; Wed, 23 Dec 2020 00:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WThy4tT62F3b3zf0PgQRiQWDvTgvmZESA9P7XUtvIQc=; b=lm/gAASMc8UZvLfJCPhTrygCJnvjXm/AgIJtR846gqbmtV/Z9xMScDs4z2klDYCZXa xitLyUpJQ7GhOJ4B/3K9Bn/OGgr46nwQda0iPJyr/MPDZ/E4Jlfcgu5f3ieDmOgniDjp VYvE8Ofugj7cXljMRJQzCHIZhclSCNeJ4ktpY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WThy4tT62F3b3zf0PgQRiQWDvTgvmZESA9P7XUtvIQc=; b=UMdjjBabjXlDtYNIjmdYaYAYsisFHT/lF92asXwkk5l1okcMFvPNlfkLubBkogRZ0U J670Z3wpn3h87vjOgCefXdK111IeHiJOzoZmXXFBxTU+E4SKcawz6sFP3s5MvauFgxv8 BfY7TwytRBzH/125O1qeXxAdGJ0Rdhu3Tn2o6VJ2cGyFrTfF16ttSLI4I/u6uPwaDt0k CKl5iOQ3IBIbEYMqWHr9STFVpVUDw7ZXtWiVbnSRYAqAzHOYM6fRrJrP8KciJdNfN250 H8pQEGgDmG7zM1Q9UhJgjQbsg+FUjmJfV2W/ZEAfPou4MwnFlkMh529SfjkprYEYS4mk IcUg== X-Gm-Message-State: AOAM531CwtxAGyWjkfa8cl6Pxp3eXIylwnp2oDB/y2S2Ax97cmpWueFY zVR99wqzSXKbQHyvt74gc8yZ3A== X-Received: by 2002:a05:6a00:1392:b029:1a3:c284:521f with SMTP id t18-20020a056a001392b02901a3c284521fmr23329507pfg.81.1608711933463; Wed, 23 Dec 2020 00:25:33 -0800 (PST) Received: from chromium.org ([2401:fa00:8f:2:a28c:fdff:fef0:43bf]) by smtp.gmail.com with ESMTPSA id p9sm22298444pjb.3.2020.12.23.00.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 00:25:32 -0800 (PST) Date: Wed, 23 Dec 2020 17:25:27 +0900 From: Tomasz Figa To: Yong Wu Cc: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy , youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, chao.hao@mediatek.com, linux-kernel@vger.kernel.org, Evan Green , Tomasz Figa , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , anan.sun@mediatek.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 15/27] iommu/mediatek: Add fail handle for sysfs_add and device_register Message-ID: References: <20201209080102.26626-1-yong.wu@mediatek.com> <20201209080102.26626-16-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201209080102.26626-16-yong.wu@mediatek.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 09, 2020 at 04:00:50PM +0800, Yong Wu wrote: > Add fail handle for iommu_device_sysfs_add and iommu_device_register. > > Fixes: b16c0170b53c ("iommu/mediatek: Make use of iommu_device_register interface") > Signed-off-by: Yong Wu > --- > drivers/iommu/mtk_iommu.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 39478cfbe0f1..09c8c58feb78 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -746,7 +746,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) > > ret = iommu_device_register(&data->iommu); > if (ret) > - return ret; > + goto out_sysfs_remove; > > spin_lock_init(&data->tlb_lock); > list_add_tail(&data->list, &m4ulist); > @@ -754,7 +754,16 @@ static int mtk_iommu_probe(struct platform_device *pdev) > if (!iommu_present(&platform_bus_type)) > bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); > > - return component_master_add_with_match(dev, &mtk_iommu_com_ops, match); > + ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match); > + if (ret) > + goto out_dev_unreg; > + return ret; > + > +out_dev_unreg: Shouldn't other operations be undone as well? I can see that above bus_set_iommu() is set and an entry is added to m4ulist. > + iommu_device_unregister(&data->iommu); > +out_sysfs_remove: > + iommu_device_sysfs_remove(&data->iommu); > + return ret; > } > > static int mtk_iommu_remove(struct platform_device *pdev) > -- > 2.18.0 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu