Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2008715imm; Sat, 18 Aug 2018 09:00:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxYvCHJbZ6VlHVQvfsDZF/8UFxyYuq4r2RxsJV6CWYItB56Nktu7Obdc6TwPSMG9OWDy++Z X-Received: by 2002:a17:902:bb0d:: with SMTP id l13-v6mr38656532pls.5.1534608012969; Sat, 18 Aug 2018 09:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534608012; cv=none; d=google.com; s=arc-20160816; b=fchISP5r5SMqIzcVt0PgJcIq4c33E2Wi9cHBoSQqoLxax4Xh0jQhfQ9RyjKe4aiybJ mD0j0evzWpStqVBQ6Ir+1293IKwQcwybsYb71u3Cxq0D/LVcljEG0QSQy7ubCxfQ4Clp 2jJLsMw5xs4hdSGMm/agVAE2avc7h/PH4fe8jWnYiD8tdh75L4eaq2jEymxp2Kn+Qjq/ ykoDNY2Mjn4OSAaeBqetsvIAtcdZ+8/CcWNiItPuuL2Ells5qVO/t71E6JmOR3zYXSHO iTnYxICq7bvFkRIIPxNZXBhzMkaqhlHWJ+oQDeLMNKD5JWww8nZoEMg5jO3jxBZxt4Bu PIdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yD2pLhYbA5LzbYbzFrw6/+GVuHxs4vnjQv6iZuDs3Hk=; b=ftRbe+5nZSwFuU5aejLGYq88261kfbTR1GtlvUURi/p8XKMd5kzPN6hhf7DHBRclUg jdJU59IRHVgjmKuAeKIW7M4jpYbDZm/tiSC4hJEB05auoq55R4PQxAiNtKJ3Ctyk74V4 piK5+Ct4TUM96ZwTdPjR9XB3qMuCuQi7V12PiOU5TkAu+R87fKD5t3omkpel+yILNAu+ ryNfP02SRu98GJ6k/MiYZjVVEK/jTPXnlNasSl7ZjGHWJdMFnOtc0DJsyHDJknVw7Slk Jxcabg4eQ3rKWEMgZtoBnJ2Z6NIL617I8tY//gqEOOxZH2mPrFKvzE/NiY5GhmDHlz08 L6aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sIgAgguX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2-v6si5086981pfc.102.2018.08.18.08.59.57; Sat, 18 Aug 2018 09:00:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sIgAgguX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbeHRTDv (ORCPT + 99 others); Sat, 18 Aug 2018 15:03:51 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37202 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbeHRTDt (ORCPT ); Sat, 18 Aug 2018 15:03:49 -0400 Received: by mail-ed1-f65.google.com with SMTP id b10-v6so6111897eds.4; Sat, 18 Aug 2018 08:55:39 -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:in-reply-to:references; bh=yD2pLhYbA5LzbYbzFrw6/+GVuHxs4vnjQv6iZuDs3Hk=; b=sIgAgguXOz1aHI/a3QLYlSch1w4/TdpFeprUhobw3D0st9oUFwfCWZbZ0J7NlEtH+S aIDr1vTgWmHAVlxEJ8xrakxmkFUxQuW3hFEwq/fafkQgi9Ew16e1Kgb20U0dmflOdO/G vSpbpFWgzN8ZQDY3dNTaVIP02wgctD6uQ7umde0CN68nmJAvQEcMiLFr7VM3D8BgH9QN sqoEFQMQLHim+ur7Ggwkpw93aW6SFLZ7nEVNGX3fxpFYwYssfe8JMEvKi5Mt3uvagEG5 6YpM7s/8iPReGmbYbbkFr15Znl5jdEjKbtjDlWCu9VFTJ1mbc4w+LVfaXmEG/hlsCwoX hyaQ== 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:in-reply-to :references; bh=yD2pLhYbA5LzbYbzFrw6/+GVuHxs4vnjQv6iZuDs3Hk=; b=MEUaBi/80Ub1kbbnFFVjgyvTHJi6nq8jLp7/ccO3YpCbJ8J5TD6MQ5PvswXl8xmZji XSaOsZNtpamkO5bRrYmRXbKGIF7qyqDybP0mHkVK1/AdbVW6+5/P1ofZdKdE8f4Ev1wI cserT3QVPgt/hO4W8cPsS6MyjgAGxZzc14Gny7IlCVzdigejYaoIUJe5Brs6g0W66vYD FSdZpagwynP2oHmWNgk9bOwuCSK+SU2j8uJr5QqYufg+OquywlnH2glkgenrQytFuH0S ivXRcsg+DaZ20StA2+Z4NZGMYfyacDuo2fG21prK0faaf+mK3M+NbiAWShDNjJRFeMs+ ftyg== X-Gm-Message-State: AOUpUlFWZbDSecpg4YPaoI8NPIOse1NOSfLe3PzfClxOGlJL4zM91H4C V0+UCtdeP9Y1WMexWCf7y9A= X-Received: by 2002:a50:8bc5:: with SMTP id n5-v6mr4271745edn.216.1534607739132; Sat, 18 Aug 2018 08:55:39 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id v8-v6sm2784014edr.48.2018.08.18.08.55.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 08:55:38 -0700 (PDT) From: Dmitry Osipenko To: Joerg Roedel , Robin Murphy , Thierry Reding , Jonathan Hunter , Rob Herring Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/19] iommu/tegra: gart: Clean up driver probe errors handling Date: Sat, 18 Aug 2018 18:54:13 +0300 Message-Id: <20180818155430.5586-3-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180818155430.5586-1-digetx@gmail.com> References: <20180818155430.5586-1-digetx@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Properly clean up allocated resources on the drivers probe failure and remove unneeded checks. Signed-off-by: Dmitry Osipenko --- drivers/iommu/tegra-gart.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 6dda7ee1d36c..e9524ed264cf 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -408,9 +408,6 @@ static int tegra_gart_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret; - if (gart_handle) - return -EIO; - BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT); /* the GART memory aperture is required */ @@ -445,8 +442,7 @@ static int tegra_gart_probe(struct platform_device *pdev) ret = iommu_device_register(&gart->iommu); if (ret) { dev_err(dev, "Failed to register IOMMU\n"); - iommu_device_sysfs_remove(&gart->iommu); - return ret; + goto remove_sysfs; } gart->dev = &pdev->dev; @@ -460,7 +456,8 @@ static int tegra_gart_probe(struct platform_device *pdev) gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count)); if (!gart->savedata) { dev_err(dev, "failed to allocate context save area\n"); - return -ENOMEM; + ret = -ENOMEM; + goto unregister_iommu; } platform_set_drvdata(pdev, gart); @@ -469,6 +466,13 @@ static int tegra_gart_probe(struct platform_device *pdev) gart_handle = gart; return 0; + +unregister_iommu: + iommu_device_unregister(&gart->iommu); +remove_sysfs: + iommu_device_sysfs_remove(&gart->iommu); + + return ret; } static int tegra_gart_remove(struct platform_device *pdev) -- 2.18.0