From patchwork Sun Jun 6 14:49:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12302049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5720C47096 for ; Sun, 6 Jun 2021 14:49:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D0596142A for ; Sun, 6 Jun 2021 14:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbhFFOvO (ORCPT ); Sun, 6 Jun 2021 10:51:14 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:19886 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbhFFOvL (ORCPT ); Sun, 6 Jun 2021 10:51:11 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d04 with ME id DqpK2500C21Fzsu03qpKgY; Sun, 06 Jun 2021 16:49:21 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 06 Jun 2021 16:49:21 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: wim@linux-watchdog.org, linux@roeck-us.net, martyn.welch@gefanuc.com Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] watchdog: gef_wdt: Fix an error handling path in 'gef_wdt_probe()' Date: Sun, 6 Jun 2021 16:49:18 +0200 Message-Id: <3d775a5ac7e26fa5dd4c47f75fef6d5f336de1e3.1622990863.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org If an error occurs after a successful 'of_iomap()' call, it must be undone by a corresponding 'iounmap()' call, as already done in the remove function. Fixes: 3268b5618f38 ("[WATCHDOG] Basic support for GE Fanuc's FPGA based watchdog timer") Signed-off-by: Christophe JAILLET --- drivers/watchdog/gef_wdt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c index df5406aa7d25..52573176101f 100644 --- a/drivers/watchdog/gef_wdt.c +++ b/drivers/watchdog/gef_wdt.c @@ -264,6 +264,7 @@ static int gef_wdt_probe(struct platform_device *dev) { int timeout = 10; u32 freq; + int ret; bus_clk = 133; /* in MHz */ @@ -280,7 +281,15 @@ static int gef_wdt_probe(struct platform_device *dev) gef_wdt_handler_disable(); /* in case timer was already running */ - return misc_register(&gef_wdt_miscdev); + ret = misc_register(&gef_wdt_miscdev); + if (ret) + goto iounmap_err; + + return 0; + +iounmap_err: + iounmap(gef_wdt_regs); + return ret; } static int gef_wdt_remove(struct platform_device *dev)