From patchwork Wed Apr 21 22:10:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ameynarkhede03 X-Patchwork-Id: 12217115 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 AA9F3C433B4 for ; Wed, 21 Apr 2021 22:12:50 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 155456144D for ; Wed, 21 Apr 2021 22:12:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 155456144D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=I329ag+GHm62XqrnURV22fic5R9rC8GOPLk7sbyaY+g=; b=pOMDs4sGhHKkbBTVhzLKzIMalC 5wZNDrJrelCtVv5dI0zl6KIinl1dUrx6QZTG3Yar+K7sFjCTISPIo1t+nJVchAOot8iPQ4VAFzBqU no5Q2RSVSMo/AbO1Fp0zuZzNCDuE5FypwDfAARMnnj65rywDyVdhlRTp2y7vpErAALT2zXuL3oQ4s rPfWnWHcS+OOlLz8ZS5JTNqLlI23QUckaJyt44p9v/tvtk4+kg4MxbWVAplfXIN4e8AfdwTO7Cjd8 NyRvN0Eh+jVl/8V8Ws/waEzE9DAvS4CKr08cpLv/VDSfr+5iZbgy/9a8zgKHMQiPpqeBi9KOfgyiq HTz/FeMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZL3d-00FGh6-GC; Wed, 21 Apr 2021 22:10:54 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZL3X-00FGgO-7Z for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 22:10:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=jkoDKXBORJsqE7IKc03ttO430VTwoSOVe4XRCyNvB4A=; b=bgucyUw0kgFepicFKjTl+//FAe xHftsHLjRESqY4BjjSDvXs9f/fEqnOa0GjFhEFLL3T2AAjtyBoiWBR2r/aH+CuQgltD96t9Xj8PAm f8H/BZuV2hCNKeBuLyka6hHF95sfQhK8YsJ0r1uQfRKIzV6pGmuSx0X0Fj1lcHpJMcfgxhN7OOJlQ PsX5cyRlqy4kNqHQIIgV+rBBBPdIHFSHCk79rZjlGqmHilqcdD+2TRTvuszZws78vxu3668Dt5Gx9 FylvnJoqNuNyf2gPw57VjJzpZUTvA1sB2ojpV7dLEXQoq5Iu3QOt0gREc3cy52C9jIp/Ape+y+vad bQYCElMg==; Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZL3T-00DDnZ-Kf for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 22:10:45 +0000 Received: by mail-pl1-x62a.google.com with SMTP id v13so8857055ple.9 for ; Wed, 21 Apr 2021 15:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jkoDKXBORJsqE7IKc03ttO430VTwoSOVe4XRCyNvB4A=; b=MyKV7gdYb+FFVYLQH1QEe30v0Ta6kUT4h9YnS7QfRbI/gZtcN53j3MCJyz7zdwxk8n KKA42sJFBo142Z5CJPfHlcF9QSanKVJAnS3tRHQyY7YZYt62hssxFwXrbkLQL+e9G8Gs z5kFTivhkQmBM8QvvaXvUcpBvflxbIiViCO24aQGjuhlL9RfN9xBcqh4oPFYUPpljaAv tr7SVQ3hjj68885dBm4b/m4Hm7W8GimDJey2ZU9z1+6my/T+GLkI7Yg6guVxTSmsvtxF 3rXfPn1lSrjf5G8mr7kF5E7Xz2AdRXBQTMhnGPXWune1Ur2uIJ+YSPO9SXMnL/Oxvitw k0Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jkoDKXBORJsqE7IKc03ttO430VTwoSOVe4XRCyNvB4A=; b=jyrJg0sWMoEg/YD1pIUO9ArJADStNkueVQ59Wl6ZarI5D+8QyddIjlnVG+SAdQGRl1 fKUTGubwxzpehrHOx6P15/2H8Pxv4GzrXncm1pWFH8G5FDcIxtftNK1r2LBezTwFOCdE decQ7bIJilLjsyy6w42/5NdwQbxehu6v8zY7zZPdZib0tcrK97DnMRo13/a5ua1KBaQL BinOjOCOKdve3ZACfyNLqQZJ3YCXNNXJUyH/tQG99DdTdVw7Z4pD6R3lHT7v36l4VNcT AtdLFmt+gpXWWRqWnrCZYg0CWTWWE2mmqX4iaGDmbq4aNPVAqcMHco8+4xoptlZ9TeH4 JLhw== X-Gm-Message-State: AOAM5310A0GzAIVLLBeULzhZEPQ3z8GKjzmpuxpEgFdQkIFAFn3CXk8A FsWe8fIKnWpCVhL8WYjWeeE= X-Google-Smtp-Source: ABdhPJzpPgM6e3+a2yGIV98aPkPhua5zknl4irN8nKi5xP/IR5IHueVdGGGiPBEMYtgp6a2gT5nH9Q== X-Received: by 2002:a17:902:8688:b029:ea:f782:5eae with SMTP id g8-20020a1709028688b02900eaf7825eaemr100027plo.15.1619043039754; Wed, 21 Apr 2021 15:10:39 -0700 (PDT) Received: from localhost.localdomain ([103.248.31.176]) by smtp.googlemail.com with ESMTPSA id a16sm308965pgl.12.2021.04.21.15.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 15:10:39 -0700 (PDT) From: Amey Narkhede To: Rob Clark Cc: Will Deacon , Robin Murphy , Joerg Roedel , iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Amey Narkhede Subject: [PATCH] iommu/qcom: Cleanup resources in case of probe error path Date: Thu, 22 Apr 2021 03:40:30 +0530 Message-Id: <20210421221030.70647-1-ameynarkhede03@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_151043_694440_7E0DE650 X-CRM114-Status: GOOD ( 13.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If device registration fails, remove sysfs attribute and if setting bus callbacks fails, unregister the device and cleanup the sysfs attribute. Signed-off-by: Amey Narkhede --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.31.1 I assume its ok to leave pm_runtime_enable in case of error. diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 4294abe389b2..5fa128a1f7f0 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -850,10 +850,12 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) ret = iommu_device_register(&qcom_iommu->iommu, &qcom_iommu_ops, dev); if (ret) { dev_err(dev, "Failed to register iommu\n"); - return ret; + goto err_sysfs_remove; } - bus_set_iommu(&platform_bus_type, &qcom_iommu_ops); + ret = bus_set_iommu(&platform_bus_type, &qcom_iommu_ops); + if (ret) + goto err_unregister_device; if (qcom_iommu->local_base) { pm_runtime_get_sync(dev); @@ -862,6 +864,14 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) } return 0; + +err_unregister_device: + iommu_device_unregister(&qcom_iommu->iommu); + +err_sysfs_remove: + iommu_device_sysfs_remove(&qcom_iommu->iommu); + + return ret; } static int qcom_iommu_device_remove(struct platform_device *pdev)