From patchwork Thu Aug 10 19:08:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9894537 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 A667F603B4 for ; Thu, 10 Aug 2017 19:08:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97E3828970 for ; Thu, 10 Aug 2017 19:08:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C77F28984; Thu, 10 Aug 2017 19:08:58 +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,FREEMAIL_FROM, 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 4E96728970 for ; Thu, 10 Aug 2017 19:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753099AbdHJTI5 (ORCPT ); Thu, 10 Aug 2017 15:08:57 -0400 Received: from mout.gmx.net ([212.227.15.18]:53110 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752889AbdHJTI4 (ORCPT ); Thu, 10 Aug 2017 15:08:56 -0400 Received: from p100.box ([193.159.17.217]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MDhba-1dqIhR0S3K-00HAMW; Thu, 10 Aug 2017 21:08:51 +0200 Date: Thu, 10 Aug 2017 21:08:49 +0200 From: Helge Deller To: linux-scsi@vger.kernel.org, James Bottomley , linux-kernel@vger.kernel.org Cc: linux-parisc@vger.kernel.org Subject: [PATCH] sym53c8xx: Avoid undefined behaviour in drivers/scsi/sym53c8xx_2/sym_hipd.c:762 Message-ID: <20170810190849.GA12659@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:+nqcd0xUBpY3fNAUatm0Sdxz5Kt428jOI7rymVKz/mXY7wwCUD1 GHj23RoJwShrZ8maMsKHdtTDXZpbPjKCkC/evzGQ+0vdIgyBvHSL+UdSpL0QdSgQmpbqKel zkLAj+9WT3pb+ktzLTOxxx0O5LogeTzdwJch0OyU12+Qq/n/dLQq3r/a3Ti0eGrUTNljt0U 0snaDX4tHYSKPJwWwgt7g== X-UI-Out-Filterresults: notjunk:1; V01:K0:S5OVCNVfSE8=:8+xPcoaGSHULyajdFN2kLi Zl+icDjWPsnaQCV3maVXkwLp8t5dpG1RQIV/5zcqUiJiPofEubmfcTyXaOlhXsHEauDjGGiMM s27Jjgw+/ryen/+jHZsY3zZ/AY7TEc+nuru3zRwSgpLyC0KXZlJgkxQuRvVZQoU7bNp5UB6sC aoRG9PnmmJFhNpR9EV5h5izEGPpfk+cxkA7yn4mgRht56gRxBWA1o6WxiC6zYCAvEz6pQ1qCt 076oWEUdWittn2KpNmpnpytrfrF+m0EKW2lNr/m0kSzVOqOrE3+ppnEFVEACZSj4QDh4y8nek vkH5tP/Q7jB/93STUs+aRXUW92wXXjDvexMsE3fNVr/AOlHPdxorXz1fauDb9/GG6akFV4eZp Nsk4kTgE2wuZzNFLYM1oavkQmXqkiPC15oXJHByndDaOpbFXfREHGHCeREf+QMW/TJ09oUIIl bsJI5HoSHkSOYijb+zJaAVikuY8Qgxim8IZjvbfyQd55PIc9Q4xH3wWqPL9tfyad0hRlhUqVz HeqXVf54VClhM23eQWdPButEl0ifVzgdp1lNmfUwl/ebssm9LrOuj5/H1EWx9zEHQIpXEnZpS EkJI8inrD6SyB3YrXl60DV4JDUQ77QdXQzE1mSZ5XXSjrloRvfS4XJOBwxYqM6kNOnY7GApU8 4HEddEL2lLZ1RtgFXc2XzW6OT2zt31fcZeYT1TxX8XuBYf52RdsH1eLP39b18N1KpSHW1w5G9 P+gEAWpcbHWibiDvGURUrdhvOlTteR75PF7UpdEUSlrshd4yhJ6jjrrbd01USWXpXr8RC6FOl NNKG4wOxIElINNt6hDTXmzsNkKwZQ== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On parisc I see this UBSAN warning with a sym53c896: UBSAN: Undefined behaviour in ./drivers/scsi/sym53c8xx_2/sym_hipd.c:762:24 index -1903078336 is out of range for type 'u32 [7]' Avoid this warning by switching to dev64_ul(). Signed-off-by: Helge Deller Reviewed-by: Johannes Thumshirn diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 6b349e3..15ff285a9 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -759,7 +759,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru /* * Maximum synchronous period factor supported by the chip. */ - period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz); + period = div64_ul(11 * div_10M[np->clock_divn - 1], 4 * np->clock_khz); np->maxsync = period > 2540 ? 254 : period / 10; /*