From patchwork Mon Nov 27 10:11:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10076335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13092602BD for ; Mon, 27 Nov 2017 10:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2281C28DCC for ; Mon, 27 Nov 2017 10:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16DD428DE4; Mon, 27 Nov 2017 10:11:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADF3428DCC for ; Mon, 27 Nov 2017 10:11:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74C2A6E244; Mon, 27 Nov 2017 10:11:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B8806E244 for ; Mon, 27 Nov 2017 10:11:10 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id x63so32836304wmf.2 for ; Mon, 27 Nov 2017 02:11:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4mg+NwKUsdC1LZVsFpXMS6ucRx7ynHDBAxObURpJj0g=; b=thdDPGpnG5A4q3Km58G0CPcitTmffK7gD5ubsmVh1yIlH775RRwpL+eDyCKM4hrMom yDvyriMtKHDKwar8kVZSEUSOmFsb+LNMiOd/ZPoT3XE4NEJzD4wyDcyY8ptsk7GfrKGi HnwRtgJ3ReIHU82N5AiU8yFqx574n8obRuj6DmiXNcltOoHq5FHXY0uXV8yT3jmc4qPQ i7obMee1TjHyT6pBkkSaDzurizv4EQM0ND7WcOISebPQC8Za4vO0UBSiHcu/monEHGdP 1ZtrfpDfSkcCkvBv2vYX23FKdgYqQPeCjXomTEi8G+cD3ElubGav+xDi64Gpoz8cfFch /Zdw== 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; bh=4mg+NwKUsdC1LZVsFpXMS6ucRx7ynHDBAxObURpJj0g=; b=HjPZbSPV+kXUjwi2Os4C8cmyeI7rCfyWhn9mawbOVOMqr19BI2iYxa6iRQzHZqCuE7 QFEm4yegONTVzjVI2Pt/42pQHvS97yroUHawEHxqoWctBackJVwU4B8c+wtw28xPv/VL FJKwZ3t2Zsx6QAIv8uCFgh1CEcI5UhZp8QKK+kra1IBxA7z18Y0RxoorKYU5PIULWqNU DQYORKzOKpQ3ZDe7lbHZiQZy+BH+6irj1l/MvSqEJWGlSHqrG1oBspZ3S7swEl0xPmk/ FzXUYDTXW0X99FmHVi5I7jUkBP31DFd0+J9+1L8l6LmHjRv6z1vlnQuYupHOmwvX4M1J tQ9Q== X-Gm-Message-State: AJaThX7TBQJ8vltySWikw8wzXe/gmFEDKWa0cO05L5DRyPBNNWaBleoD 50n0V3vExJ3L0wMkgfPL8Po= X-Google-Smtp-Source: AGs4zMZzx6U4rXAEzrbXHzv3FKvLgMvFuQfW9xMt9NMTK+4A/zx4yG6UA2M+XxsAdMmNsVhoV1LNmQ== X-Received: by 10.28.209.77 with SMTP id i74mr16524940wmg.53.1511777469062; Mon, 27 Nov 2017 02:11:09 -0800 (PST) Received: from localhost (p200300E41F200F003F65F430A8AE2E44.dip0.t-ipconnect.de. [2003:e4:1f20:f00:3f65:f430:a8ae:2e44]) by smtp.gmail.com with ESMTPSA id k2sm979057wrg.4.2017.11.27.02.11.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Nov 2017 02:11:08 -0800 (PST) From: Thierry Reding To: Thierry Reding , Mikko Perttunen Subject: [PATCH] gpu: host1x: Cleanup on initialization failure Date: Mon, 27 Nov 2017 11:11:07 +0100 Message-Id: <20171127101107.22709-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.15.0 Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding When an error happens during the initialization of one of the sub- devices, make sure to properly cleanup all sub-devices that have been initialized up to that point. Signed-off-by: Thierry Reding --- drivers/gpu/host1x/bus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 2e57c9cea696..88a3558b7916 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -211,8 +211,7 @@ int host1x_device_init(struct host1x_device *device) dev_err(&device->dev, "failed to initialize %s: %d\n", dev_name(client->dev), err); - mutex_unlock(&device->clients_lock); - return err; + goto teardown; } } } @@ -220,6 +219,14 @@ int host1x_device_init(struct host1x_device *device) mutex_unlock(&device->clients_lock); return 0; + +teardown: + list_for_each_entry_continue_reverse(client, &device->clients, list) + if (client->ops->exit) + client->ops->exit(client); + + mutex_unlock(&device->clients_lock); + return err; } EXPORT_SYMBOL(host1x_device_init);