From patchwork Tue Feb 7 08:10:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9559359 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 55ADC60216 for ; Tue, 7 Feb 2017 08:11:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47F37204C2 for ; Tue, 7 Feb 2017 08:11:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B3A628178; Tue, 7 Feb 2017 08:11:03 +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 BC179204C2 for ; Tue, 7 Feb 2017 08:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751927AbdBGILB (ORCPT ); Tue, 7 Feb 2017 03:11:01 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:48690 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752530AbdBGILA (ORCPT ); Tue, 7 Feb 2017 03:11:00 -0500 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OKZ01HFCW1L0220@mailout1.samsung.com>; Tue, 07 Feb 2017 17:10:33 +0900 (KST) Received: from epsmges5p5.samsung.com (unknown [182.195.40.64]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20170207081032epcas1p1372c802747e8697a032d0a7d0f44ba82~g8voYfypa2908229082epcas1p1F; Tue, 7 Feb 2017 08:10:32 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p5.samsung.com (EPCPMTA) with SMTP id A1.65.04795.8F089985; Tue, 7 Feb 2017 17:10:32 +0900 (KST) Received: from epcpsbgm2new.samsung.com (u27.gpu120.samsung.co.kr [203.254.230.27]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20170207081032epcas5p3af837bbe00278da4029fc7bb9eba6961~g8voH8vHZ1028210282epcas5p3s; Tue, 7 Feb 2017 08:10:32 +0000 (GMT) X-AuditID: b6c32a59-f79be6d0000012bb-1d-589980f81370 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id B6.53.06428.8F089985; Tue, 7 Feb 2017 17:10:32 +0900 (KST) Received: from gangnam.samsung ([10.113.62.47]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OKZ00E5NW1GUZC0@mmp2.samsung.com>; Tue, 07 Feb 2017 17:10:32 +0900 (KST) From: Andi Shyti To: Krzysztof Kozlowski , Mark Brown Cc: Javier Martinez Canillas , linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 2/2] spi: s3c64xx: fix potential division by zero Date: Tue, 07 Feb 2017 17:10:25 +0900 Message-id: <20170207081025.9671-2-andi.shyti@samsung.com> X-Mailer: git-send-email 2.11.0 In-reply-to: <20170207081025.9671-1-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmhu6PhpkRBs+3WVlsP/KM1WLxj+dM FlMfPmGzePN2DZPF+fMb2C0u75rDZjHj/D4mi8aPN9kdODyuL/nE7LFpVSebx5b+u+wefVtW MXp83iQX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qSQmpecn5KZl26rFBripmuhpJCXmJtqqxSh6xsSpKRQlphTCuQZ GaABB+cA92AlfbsEt4z5NxYwF8xjr1iz8Q1bA+Nb1i5GTg4JAROJLe+Ws0DYYhIX7q1nA7GF BGYxSjw7ptfFyAVkf2SUOL/1GztIgk1AU6Lp9g+wIhEBL4kJM+6xgRQxC9xmlPi0aw8zSEJY wFFi47Y3YEUsAqoSV9Y3gsV5BawkPt1azwyxTV5iV9tFsCs4Bawldq7fyQSx2UrixIsXLBMY eRcwMqxilEgtSC4oTkrPNcpLLdcrTswtLs1L10vOz93ECA7vZ9I7GA/vcj/EKMDBqMTDG8A5 M0KINbGsuDL3EKMEB7OSCO+xWqAQb0piZVVqUX58UWlOavEhRlOgwyYyS4km5wNjL68k3tDE 3MTc2MDC3NLSxEhJnLdx9rNwIYH0xJLU7NTUgtQimD4mDk6pBkbrk7wcc21ClxZ4Kzm/rjZe VhI6bb8OM0dxTrWqZYmq2AGmPG2NZ5+bIsoX3TqrujPsJeuaDXt7NUL9gg6t43qpUle9VFSl zpVPc37RB9Ocp9Vyz9b0MQsnrtYyLt6Qa3TfK+796i1/Xl377XvfW/UD76a/5Rd0KlKv10lF tx2wOxO0RoG/X4mlOCPRUIu5qDgRAHeKHn6FAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170207081032epcas5p3af837bbe00278da4029fc7bb9eba6961 X-Msg-Generator: CA X-Sender-IP: 203.254.230.27 X-Local-Sender: =?UTF-8?B?7JWI65SUG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLzthLAp?= =?UTF-8?B?G+yCvOyEseyghOyekBvssYXsnoQ=?= X-Global-Sender: =?UTF-8?B?QW5kaSBTaHl0aRtUaXplbiBQbGF0Zm9ybSBMYWIuG1NhbXN1?= =?UTF-8?B?bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1NUQUYbQzEwVjgxMTE=?= CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20170207081032epcas5p3af837bbe00278da4029fc7bb9eba6961 X-RootMTR: 20170207081032epcas5p3af837bbe00278da4029fc7bb9eba6961 References: <20170207081025.9671-1-andi.shyti@samsung.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even though it's quite unlikely to happen in this particular case, clk_get_rate can return '0' if sdd->src_clk is not set properly. In that case we would have a clear division by '0'. Check the return value of clk_get_rate and fail in case it returns '0'. This patch fixes '1397922 Division or modulo by zero' from scan.coverity.com Signed-off-by: Andi Shyti --- drivers/spi/spi-s3c64xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index f6ea9ae047ec..a2ec07f44e33 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -811,6 +811,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi) /* Max possible */ speed = clk_get_rate(sdd->src_clk) / 2 / (0 + 1); + if (!speed) + goto setup_exit; if (spi->max_speed_hz > speed) spi->max_speed_hz = speed;