From patchwork Sun Dec 17 15:40:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10117749 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 59C4560327 for ; Sun, 17 Dec 2017 15:41:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60037292A1 for ; Sun, 17 Dec 2017 15:41:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55243293A2; Sun, 17 Dec 2017 15:41:10 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED8BE293C8 for ; Sun, 17 Dec 2017 15:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757222AbdLQPlF (ORCPT ); Sun, 17 Dec 2017 10:41:05 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:42160 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbdLQPlA (ORCPT ); Sun, 17 Dec 2017 10:41:00 -0500 Received: by mail-wm0-f65.google.com with SMTP id b199so25227561wme.1 for ; Sun, 17 Dec 2017 07:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=73jMKN4nyxaJlt9aF2NGTOkfaal1QM0GK5Oqz9hVEFc=; b=THLumL44k7pKFkvJ0G6o0IIY89VtVXDZFTNN5kbMBj0SjfAi+IFvifqOfiqY650/Qo iIHK/u8D09DkxO1vJUHpgfhd07v9WIC0Spwrke1m/naDbIA3Ydi9as3jKeFIrI4+eckV C+gbJ1L1mDr2DLlUqLxLC1J1LarEntR6dmjd3MO140DDJZ+/F1tZ34lqsgXRWtwJCjHG aaR2KfgVxIk2mFnVS8ddGFwSk3UNO4lxKOCgvfaaXxkIgQBNOZTEM8sKB8jGO9vpmlRX oHQKoaIuINZ0jJY3R3Q5/AN7JVUl4tvvuaHzXJpUHkUNaRaSxEk0o/1nYJUhZSTWXHpc TGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=73jMKN4nyxaJlt9aF2NGTOkfaal1QM0GK5Oqz9hVEFc=; b=st8SPwuBuEcOQHpvb1SjgDz/ERDT+vv+2qLa7mluRMvJNd+Q1ol3Oz+ix4LJeU0YNQ y+2lfuZr20Oqhq/VKuddSBRkaobkK3FbthrHpFlqhjEd7BREH06SVLzg0igx/dEk73yF d4S46vvK4xGybZpRssqfz/ZmU+Dt/EFLwGBy6vv8kJtzKwloppXSauMLguQa6tfXuGEH yjiJbCM3046vcMPawQqoWBeFc0NtAz98BIdhKXoc+KvhB1q9yk/l/LYPjIaSwKOE7Y5x uSrFW1pZhFmLj3kmkdXllPpROWvvfKlVlmYN/f6PqsPNldLqyxVCnaKlxMxzVk2x5Adl mygA== X-Gm-Message-State: AKGB3mI2SlXNK9nhWL1qBLat0ON4DLRKWqkTBc38+DnF/RqZtqNdBCyf 4tK7PgT8Chxs7lkmpXNpAcR2WQ== X-Google-Smtp-Source: ACJfBos4rDIu6HyGf8GYqTfzwQzhpzjuWbO/2Jl5pKSD3TU2tx6hyXjzPDOko+JaBK0KI6BK2fsJSg== X-Received: by 10.28.191.3 with SMTP id p3mr9419277wmf.81.1513525259272; Sun, 17 Dec 2017 07:40:59 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id m52sm2420974wrm.12.2017.12.17.07.40.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 07:40:58 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH 6/8] [media] ddbridge: fix deinit order in case of failure in ddb_init() Date: Sun, 17 Dec 2017 16:40:47 +0100 Message-Id: <20171217154049.1125-7-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171217154049.1125-1-d.scheller.oss@gmail.com> References: <20171217154049.1125-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller In ddb_init(), the deinitialization sequence isn't correct when handling errors, and could even lead to a memleak depending on where things failed. Fix the deinit order. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 07f3e37a0fca..548b7047ca09 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -3273,7 +3273,7 @@ int ddb_init(struct ddb *dev) ddb_init_boards(dev); if (ddb_i2c_init(dev) < 0) - goto fail; + goto fail1; ddb_ports_init(dev); if (ddb_buffers_alloc(dev) < 0) { dev_info(dev->dev, "Could not allocate buffer memory\n"); @@ -3291,14 +3291,14 @@ int ddb_init(struct ddb *dev) return 0; fail3: - ddb_ports_detach(dev); dev_err(dev->dev, "fail3\n"); - ddb_ports_release(dev); + ddb_ports_detach(dev); + ddb_buffers_free(dev); fail2: dev_err(dev->dev, "fail2\n"); - ddb_buffers_free(dev); + ddb_ports_release(dev); ddb_i2c_release(dev); -fail: +fail1: dev_err(dev->dev, "fail1\n"); return -1; }