From patchwork Mon Apr 24 21:34:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9697277 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 B5A36603F3 for ; Mon, 24 Apr 2017 21:35:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A87A12818A for ; Mon, 24 Apr 2017 21:35:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D42928423; Mon, 24 Apr 2017 21:35:00 +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=-6.9 required=2.0 tests=BAYES_00,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 79D642841D for ; Mon, 24 Apr 2017 21:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S978149AbdDXVe4 (ORCPT ); Mon, 24 Apr 2017 17:34:56 -0400 Received: from mail.kernel.org ([198.145.29.136]:36592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S978117AbdDXVeg (ORCPT ); Mon, 24 Apr 2017 17:34:36 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 573A220173; Mon, 24 Apr 2017 21:34:34 +0000 (UTC) Received: from localhost.localdomain (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C21AB201B4; Mon, 24 Apr 2017 21:34:32 +0000 (UTC) From: Alan Tull To: Greg Kroah-Hartman Cc: Moritz Fischer , Alan Tull , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, Tobias Klauser Subject: [PATCH 2/3] fpga: region: release FPGA region reference in error path Date: Mon, 24 Apr 2017 16:34:21 -0500 Message-Id: <20170424213422.3190-3-atull@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170424213422.3190-1-atull@kernel.org> References: <20170424213422.3190-1-atull@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tobias Klauser If fpga_region_get_manager() fails in fpga_region_program_fpga(), a reference to the fpga_manager instance previously acquired through fpga_region_get() is retained. Make sure to properly release it in the error case by using a separate jump label which will call fpga_region_put() in before returning. Signed-off-by: Tobias Klauser Acked-by: Moritz Fischer Signed-off-by: Alan Tull --- drivers/fpga/fpga-region.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index ae4c61a..3b6b2f4 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -245,7 +245,8 @@ static int fpga_region_program_fpga(struct fpga_region *region, mgr = fpga_region_get_manager(region); if (IS_ERR(mgr)) { pr_err("failed to get fpga region manager\n"); - return PTR_ERR(mgr); + ret = PTR_ERR(mgr); + goto err_put_region; } ret = fpga_region_get_bridges(region, overlay); @@ -281,6 +282,7 @@ static int fpga_region_program_fpga(struct fpga_region *region, fpga_bridges_put(®ion->bridge_list); err_put_mgr: fpga_mgr_put(mgr); +err_put_region: fpga_region_put(region); return ret;