From patchwork Wed Apr 5 20:10:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13202446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B854C76188 for ; Wed, 5 Apr 2023 20:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Cc:References:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JQkTZpMp3UDw2e/AOedE7Qiu+tfL+UP4Ys4UR0qF2T0=; b=sRW/aAYXEthnDg yqal2I2Xrdm1yanRKUcenU514UV/B0I/JsePzF9IVt9+Zb/9PJbkAGKvAtZve0jWU2Tv6F+QzoqLr kBaAhdF/F+sTexp4ueLd+2ZEKcana2yXIh+VOsko2TCh6bYCZ8uewr9PXNTuvyAyP4gooSXY7sfz8 K/zlP8djB6DTxPGc/XWv1a8OdFVj0H4cIAspmJWEAQkoRbfB+CcaFnIV55WW0N1g5uKo9Iui/1FV9 w2cWXPINBGLlPMRaG+mTPIbcnBhdtqfSVpNPs/vDgqLqnvNPOyiyigoft4Qc+6/2Z1nm/o35c5WfP yOk9TcShccyVwobXO7zQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pk9Sb-005apO-1W; Wed, 05 Apr 2023 20:10:25 +0000 Received: from mout.web.de ([212.227.17.11]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pk9SX-005ao4-1j for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2023 20:10:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1680725413; i=markus.elfring@web.de; bh=r9cMMDa8l5YOvWJW+ICwbfkpgZcbEvm5JZZjaOYeeH0=; h=X-UI-Sender-Class:Date:Subject:From:To:References:Cc:In-Reply-To; b=VoNMPbJh7YnJ890eEKv6pHGxIPNnq8skzTi1prqY3noqygLl1egFwEGOPJwT8+X8d if/wEiw41SNeEYcSIez8MPDIHtvhgJOSYct9JYguGJ7daFPTADWCZg9vvWybYEIJUm 4qSDxCZdNyb/bVwhpMifnBf+55H2KuryeefXzUhUan3Fym2lX092ay+OLc75LNuURJ 2rmuQYcy8mSpKxOn/Et7yj6TyDY+vN9lgkcJBmhaP54roaWpbCQdHwICp27zMFQM8K OTBW7ezy9AkNZ5MtvArZB79kAbRSySHH7Nvgto4kHJaxyuCQ0ccUlPAPQ5mqAJuWZN nVif51gXryEWQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.82.83]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mc1VF-1qGBxK1Fkt-00dEis; Wed, 05 Apr 2023 22:10:13 +0200 Message-ID: Date: Wed, 5 Apr 2023 22:10:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH] firmware: ti_sci: Fix exception handling in ti_sci_probe() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nishanth Menon , Santosh Shilimkar , Tero Kristo References: <8f785de5-ebe2-edd9-2155-f440acacc643@web.de> Cc: cocci@inria.fr, LKML In-Reply-To: <8f785de5-ebe2-edd9-2155-f440acacc643@web.de> X-Provags-ID: V03:K1:o57QYOW9BaxSczMGrkrf2rb2nCYebWEf6LNyxCDdCgC7xJwozyR kP19wA0aQxHXJXXVLFS6sDUKtMR4ZvX1aNB/RIrD/6Dupq7IZT/NszOG6cETG6pnlR1l+qg hbJnbYqswZWoLGbu8HWdmkmig1gd5ymaIq+NTPb8wqepEEgcTHs5b46yGRivs5Jy8KxwMft wgmK50gwBqVRC5SX7TUlw== UI-OutboundReport: notjunk:1;M01:P0:DGCeGnR9leg=;a+M1j7UTp9oAeRd5NKp0Bl++VYH WSqxLqnc0UBS9Qaj8bvK0O5oPZho2koYI1wszSlz3A37WHg5oz5rw0CAXA6BT5c4/O1WzecxA NyYXMSHH7Wu2QY1+AtRR5lZWo6YHaSFZ4YUJlnqijz5aBsXGtDhchV4S18TeASOwmUfmxSS/u 8P5d2cVLyZCpcWL076Fn7xkF2I+ywmm48KWQLSZFHhG5uP0uPhOYohc414xFc6HOaDDGTiByG eSPWJVErq4mk6fDbzL21+3Ud3x0ri5/WF1I/jnBUP4sYJFALWOwr3Ee6IlyexEfMPNovU22ZP 8xuFl8nHzgymYbAB7c5hCm9RhGM4W+83LoV/2GZtyey6AaNSRWiWaTsbbs8VHouLc7vF5yLH5 IlilJwLtYPo6bYuJ7wPO1O8fab4kchgQdYS/EJ/JHyPioWPFBikYo66mWbDN9KP6dElc8U4sU h9y/LAkBrtM+AitjJwWhBpUH6ZMd48eU3CT2qAMmGIieIARR3AVvDjTLXIo8jlrOJB0K7slbn pcB8pUghqXmV8Ic/t0V9TkxOf1n5czXo0xxwi7LGjygKIRSSkJJ+JcZV6KVFuhoFkJUQNuhUE HuHUyUj9E2itIreE1qaeGwVH9wJ9pS1DfKmUVyB8qU0LtIOqfDV59nozvDiYqwsOrjGzlxIgI OeVvaSFEPuldJlRoTOkviavGSxYeyqGuYU0NId81tx7Nfur2hzcgNK/U+3NITBEHR9Arf7rGA sTMP67LgPDzNybpwReuTnfrsaSrR0oYywl8Qv0NJQXGEUujvD52dUNuVHGM9G/4bDRPnB2o8r NOfzRyllTRxMBTupWgtI7P+VvHrvXDWVY68TkfKn9ba9+mFsFb33LWAjiUKr12yu69djGWKbL +e3m1j6l0jv2Mfa1k2SsTPWIzo/GhaLFKsCrtwiy4fhnl2fsYXqWoszry X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230405_131022_049533_B89166A1 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Date: Wed, 5 Apr 2023 22:00:18 +0200 The label “out” was used to jump to another pointer check despite of the detail in the implementation of the function “ti_sci_probe” that it was determined already that the corresponding variable contained an error pointer because of a failed call of the function “mbox_request_channel_byname”. * Thus use more appropriate labels instead. * Delete two redundant checks. This issue was detected by using the Coccinelle software. Fixes: aa276781a64a5f15ecc21e920960c5b1f84e5fee ("firmware: Add basic support for TI System Control Interface (TI-SCI) protocol") Signed-off-by: Markus Elfring --- drivers/firmware/ti_sci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.40.0 diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 039d92a595ec..77012d2f4160 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3433,18 +3433,18 @@ static int ti_sci_probe(struct platform_device *pdev) info->chan_rx = mbox_request_channel_byname(cl, "rx"); if (IS_ERR(info->chan_rx)) { ret = PTR_ERR(info->chan_rx); - goto out; + goto remove_debugfs; } info->chan_tx = mbox_request_channel_byname(cl, "tx"); if (IS_ERR(info->chan_tx)) { ret = PTR_ERR(info->chan_tx); - goto out; + goto free_mbox_channel_rx; } ret = ti_sci_cmd_get_revision(info); if (ret) { dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret); - goto out; + goto free_mbox_channel_tx; } ti_sci_setup_ops(info); @@ -3456,7 +3456,7 @@ static int ti_sci_probe(struct platform_device *pdev) ret = register_restart_handler(&info->nb); if (ret) { dev_err(dev, "reboot registration fail(%d)\n", ret); - goto out; + goto free_mbox_channel_tx; } } @@ -3470,11 +3470,12 @@ static int ti_sci_probe(struct platform_device *pdev) mutex_unlock(&ti_sci_list_mutex); return of_platform_populate(dev->of_node, NULL, NULL, dev); -out: - if (!IS_ERR(info->chan_tx)) - mbox_free_channel(info->chan_tx); - if (!IS_ERR(info->chan_rx)) - mbox_free_channel(info->chan_rx); + +free_mbox_channel_tx: + mbox_free_channel(info->chan_tx); +free_mbox_channel_rx: + mbox_free_channel(info->chan_rx); +remove_debugfs: debugfs_remove(info->d); return ret; }