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: 841593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="thdDPGpn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yljHg0wBbz9s7F for ; Mon, 27 Nov 2017 21:11:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751509AbdK0KLK (ORCPT ); Mon, 27 Nov 2017 05:11:10 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38435 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311AbdK0KLK (ORCPT ); Mon, 27 Nov 2017 05:11:10 -0500 Received: by mail-wm0-f66.google.com with SMTP id n74so7983577wmi.3 for ; Mon, 27 Nov 2017 02:11:09 -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=jns3wUZsAX1rGh50GDaC75en94O2Omvh0Ah+1QSxpfpCNM9oyjxH3khcX5WjCOkh22 T6GmX0IyUJRq5DsGfHNuHZJG7xhinIyAwRV7kChb9s7axEZDiQUS0ICWwzJfyPXf8DXh 5aqCDfelHZl7ck0f8I8z4K/y6ToGjQpCAv8acwVueQZ+AieKPQD0KYG007PtajzJPsAF miFbNqy9GokTz0zUkDfj/Dd5XWOId6qkTVCWaRzxc90IjXCBfSlqQqGxgFP5b2Jo1+JZ daJEbs5QoBYxHq14s9HZ0N+kwFOIbp19q2FACKiSLj9YO5C+UuxXOtaTG9JLOL0zrtk0 2gkA== X-Gm-Message-State: AJaThX7q+OoSIwGYL3FC1cNUrHuLIXT8wmjlcCBQeVrjBzhtKrilyk/B XFO+GdCOtvKflnZ4L4tjTu4= 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 Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org 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 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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);