From patchwork Fri Apr 7 06:22:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13204472 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 5EF36C6FD1D for ; Fri, 7 Apr 2023 06:24:36 +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=BqtiAVaA0pM87ZWGOrg8IB5j2qbEjnoZWDU+czychfk=; b=LVIL80K/OeNp/5 AAGwfMOjiW3sBaKQJNxfLB26aw6G4RdlrT6Ds88wBk9GAE9roKnD+CDzzluTnov7Xs8Ok+RLSu2S1 DE6jB1E3cXyVayjx8qM33/DFH+Fku8smU5ysARKL6zUa+WwV6KM7m88HrfdOznR06vKgSQHUuTIY7 YxULjBqGRcmPpmTq34IdyYsQkxHc3lfwrraCXEfQX3WJ4N0XUGoiuYwIhYJSQSdpO93tAmXq7IMMj gK3Yo0r7vzkXX/eTma5xBHtaiBeljlbKmAQu/g+aeQt7heKU32HJqqc9I9fMECu+Ay50wkE5fGXBs 0RrdD8d/1chuqcLiwzcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pkfVM-009GT3-0J; Fri, 07 Apr 2023 06:23:24 +0000 Received: from mout.web.de ([212.227.15.3]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkfVJ-009GSj-0g for linux-arm-kernel@lists.infradead.org; Fri, 07 Apr 2023 06:23:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1680848580; i=markus.elfring@web.de; bh=Q07bSq+vKNvcQzVSQ4b4EDli2tQSjN9qtpe+7WIT/sw=; h=X-UI-Sender-Class:Date:Subject:From:To:References:Cc:In-Reply-To; b=gTOUGWmnRalwMG8N5oA9uqqWJzltGvvmW7W/mg5MQGup8Zqhe+8IcxFDi0ooYtlka 5Iw3BM6huDJJr0WhHGKIxvW/EVkcoG87MkwcP6GU6jHUdClb2bg1DgE3YuD5hDRCXC e7ry5XC1uGSoarHoSMT8KGQIt40IBtohf9gN5xElvlQn0Yo6ANgDgHEmlbQuyrvYjM IGcR0GjJj/2A89SRLd+WwUM1vaJfOBmyDGZEyE2JZKMi2hKekkUQR5zA5d3COdLL86 qUv4JBKs5xaZFS9DtJXokJu937wr6Y40RoZ6WqyxT/3iLqezZJsu80IrdsNyBNK6h7 reZLqQr32jGlg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.83]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mpl4z-1qBhvt2u3p-00qE7u; Fri, 07 Apr 2023 08:23:00 +0200 Message-ID: <82aebf6c-47ac-9d17-2d11-6245f582338e@web.de> Date: Fri, 7 Apr 2023 08:22:50 +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] spi: atmel: Improve exception handling in atmel_spi_configure_dma() From: Markus Elfring To: kernel-janitors@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexandre Belloni , Claudiu Beznea , Mark Brown , Nicolas Ferre , Tudor Ambarus , Yang Yingliang References: <8f785de5-ebe2-edd9-2155-f440acacc643@web.de> Content-Language: en-GB Cc: cocci@inria.fr, LKML In-Reply-To: <8f785de5-ebe2-edd9-2155-f440acacc643@web.de> X-Provags-ID: V03:K1:6oy7YoYoFrpIkRnQd8A3LwdEpt1ogKfSbyN03ICHz79PNH74dV3 Yj+Nif/hVoFxu92IpmvpKIpayy3G9YaKwokrorPJLYvUulZstFW1cYc4acH2nTk959/Wy44 0rZKneblBQ1Uqjafj8uJtPLDlQ1C/CQjq1pEMbP3sW+cPP/Y95XgspScv8vsW0lGDSd9E8q W8P8r7nr9cJBGShWyxYmQ== UI-OutboundReport: notjunk:1;M01:P0:znbifOoJL0E=;c1X1Tnnob0NlNlMyGSY4ypfH3b3 32d4+zdkBBn+/1T1kt6la8+25iFOTUtRs+5S12u69LmeyxFXEpHR9A3byfX/mpFNLgCyrQRiK bXvN+Xrihbobiln/J/mPmZBAnAZDqhLoD9j/a21fw7Ri81VNS9xEe50rhrcW2zp9Xl3j6YbVw 15hI5eCFBVsE2uQep0BcN0yBXLE4VT2sQhR686yz4AhJK35qTmGP7TEPprh/GM6RS7dqjjUfJ uXKOR6t4a2jGeHfdgqy5YZY2/RkzN4WgcsOy3UiHE4foTipbI/4jZVIiucH72hJClmja7k4Kf mkqmtrZXHtYYD4qelbZZtp8sDYeXjzDOC7BfwjQ32vB8vnRop3U8Nvp90gI57yidK7SNa7f5n iHVCGZN1PuwdhWcJ9p++FYP7EStJoKF1f8m6vAkVHAli6oj42POYD3sP0qWXPeyj4TibVB50+ joI9zGmzdrEvIrVfMNgrLhBrgonE14WK1XXvAWvgeOeeseYtmmvwUzHjSAwIjbzVDRUrpVEN2 vW3vVUdkEJ9baalPSCdfyzeRCly0FCyxXEv//tVBvNQLc4YAf3oQ0gJAWQX/KzAQ8OANcIjap adrxfpOu+jezqkfIXU/5m3No99///r0AEkjYg+6SjnwxCp6FfMMSzGaN+z84uoI06yPG4L3Fu bjqZUx1TFn2wpLs1BriHxra2Wm0T6pRpOm6GixJLMUzwD/Iiiy6m/L8eDThCemR/WiSmwUbD+ 076cOVmJplDk1Bp5wfgM1iq0yfZCRSA09JuwUT6Esln5DYme5Iikja5kYGX9TECzKQtNo+Q9r ivL+GAb0LwGMb9ACEqLVGJYhHeZY3QO9U4b1pqd7r9Gcl7nMwgEQUokLDPJbF3PcmtBqwlGPa N3xR6NTRzIiI/eC7gYWcIeznbhLJ8o4ttEW/eRmvXsEl8j30RseKv0cRJ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230406_232321_735313_E4D1B510 X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. 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: Fri, 7 Apr 2023 08:08:59 +0200 The label “error” was used to jump to another pointer check despite of the detail in the implementation of the function “atmel_spi_configure_dma” that it was determined already that the corresponding variable contained an error pointer because of a failed call of the function “dma_request_chan”. * Thus use more appropriate labels instead. * Delete two redundant checks. This issue was detected by using the Coccinelle software. Fixes: 398b6b310ec85eef9d98df5963d5ded18aa92ad8 ("spi: atmel: switch to use modern name") Signed-off-by: Markus Elfring --- drivers/spi/spi-atmel.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.40.0 diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 7f06305e16cb..ed8dc93c73e5 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -511,12 +511,12 @@ static int atmel_spi_configure_dma(struct spi_controller *host, * requested tx channel. */ dev_dbg(dev, "No RX DMA channel, DMA is disabled\n"); - goto error; + goto release_channel_tx; } err = atmel_spi_dma_slave_config(as, 8); if (err) - goto error; + goto release_channel_rx; dev_info(&as->pdev->dev, "Using %s (tx) and %s (rx) for DMA transfers\n", @@ -524,11 +524,11 @@ static int atmel_spi_configure_dma(struct spi_controller *host, dma_chan_name(host->dma_rx)); return 0; -error: - if (!IS_ERR(host->dma_rx)) - dma_release_channel(host->dma_rx); - if (!IS_ERR(host->dma_tx)) - dma_release_channel(host->dma_tx); + +release_channel_rx: + dma_release_channel(host->dma_rx); +release_channel_tx: + dma_release_channel(host->dma_tx); error_clear: host->dma_tx = host->dma_rx = NULL; return err;