Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp906809ybh; Tue, 21 Jul 2020 10:44:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTUVemRJ/QU5GnkVNQVbIz2LBCTwaEjDZwPPFKLB/y0YbfBeEnGxASwhoPK5yImrRqe6Ij X-Received: by 2002:a50:8e53:: with SMTP id 19mr27808473edx.185.1595353448430; Tue, 21 Jul 2020 10:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595353448; cv=none; d=google.com; s=arc-20160816; b=wNicoVYAfsv+eLy99NMIbQO1dHX+pwH846tUnud+e9vWUC0L9pcScRqlJi2QBMEvMi kmW95/dlgtxHH+83DT76l5nOTql3jLO1MVlGjbmT/+EdRoJ5/FiGAhshNYEn3Z01cagX 07GiVp2Ts0NWokjOab4qfrQFFflbpOJ7htNNcVJVYPI92tUve5zAfH0QA8xvAsFfJ1Lo 3+v8mm1IEZZwk1NegkaIam7iUf/qksjuhJC213bF8ewnWYC/54OSQNkjLgWudEK+Ysnu G2PUVwW2+28bqJwp0cx3MqRT47GH+2UrdP9o94iAMf9xXtoFip3+sGDEF2aunzP4zP7z 85BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=E4KZgwVTI5aMyqyLhFG3oLM6lp0QMlQ+v/7xrQ4lxDs=; b=ffSvUF66gRbrYCdGNHSsVGZbLzHJ3px3m1FOyEXUVqxSHmAJnSDwZ+zJlCIAfD8zUm VCT7Lj1VrCF38Vc0tK9i8upwvHfUkk3ZkTOIlUAQxGs2OHvtgo30vFBX9kHseSGUDurP i1WbS3pnioTc5Y4iC57u/Ao5bJfyb+effZHZuaXViObasMTl5wNxg2WN3PUzpsMRQCf1 xE28NKi/jOy33TVKji4qS4N4IhGLc9Qw6aRvdvlSNsL5CNHlxyibTIIis1ZKkqt2MsgC egGNgUOviR9MeHuth3rVsd+Aq48cXHtOjPERVJJET792SC3GO6jIU/D8FdgN3IQpXS/c k8+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b=oZ3BrUtm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si13179738edx.295.2020.07.21.10.43.45; Tue, 21 Jul 2020 10:44:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b=oZ3BrUtm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730909AbgGURmh (ORCPT + 99 others); Tue, 21 Jul 2020 13:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730868AbgGURmf (ORCPT ); Tue, 21 Jul 2020 13:42:35 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7872CC061794 for ; Tue, 21 Jul 2020 10:42:35 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id s189so12258498pgc.13 for ; Tue, 21 Jul 2020 10:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pesu-pes-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=E4KZgwVTI5aMyqyLhFG3oLM6lp0QMlQ+v/7xrQ4lxDs=; b=oZ3BrUtmP+vLY3N3slRcKIuQ7yd0ZvpzWXZDGA+txT2uXl3KtRkQlZPRYpMbmi0nDm gnT49lqnyjoTGBDP4UE1OYnWpllTkB0baayRG9MWBNY0yCXj6rJJuhW6pUtw47yJuh7a jpRAvlP4Lb45W2/c/Ltk/q1+fTOpnqu+UbhjpVaH64FNUgsKqQPvKT1KpQSsOabJTKz2 89puFcMefNK36uviukBAAf2brQGgMcj2NvPx84gCPJZqt+afp6j5JNdzBylBzMe15xNq fM2tN2jRjr6WMGttsZTUQMQfz3XBcBzAr+Jq3AHnLJQp2IpCOPIAECew14TlNXeDoqor h80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=E4KZgwVTI5aMyqyLhFG3oLM6lp0QMlQ+v/7xrQ4lxDs=; b=EMdI0I8L379F/BgltiMJGB4RcONFJyu+IuXQMLMSTObHmfpLx87BqB7tvhZ8V+iFEE v7IPPecUt0j4gXh3gDGrEVLJxtY1WXE49oqRar+r1PfbimfWzNcHtJ6fmFbqHiR/6iwK /+CPJC9kH0R5pBdAZxRdpMB9TL0FW3GWM6kMAclJD2aI93EOYpOlWk7oCmp3bmjAbHWw gwWJlQtuRCTyUERm25xtqPwb8nXZ6YWJD0U3wXFh0Un63ocJ1zFVX9zNxgZfJs8gxHZg vZgJ70OSoBTVZox52Y1dtwZb7U0Ij+z3QOnoGDpdntcxoue3J/he404WFi2NXEfQAd8o SBUg== X-Gm-Message-State: AOAM531ubVr/nT9iV+1PV2pynNwF7aUISksFe/NT7HfI2JL7zJo0mPCL 2F209kTxGvmT/T82RPlCy/6Kgcczd8I= X-Received: by 2002:a63:5b05:: with SMTP id p5mr23096072pgb.143.1595353355016; Tue, 21 Jul 2020 10:42:35 -0700 (PDT) Received: from localhost ([2406:7400:73:d7b6:d055:3e56:d1e4:ce99]) by smtp.gmail.com with ESMTPSA id q14sm18238201pgk.86.2020.07.21.10.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:42:33 -0700 (PDT) Date: Tue, 21 Jul 2020 23:12:29 +0530 From: B K Karthik To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Vabhav Sharma (OSS)" , "bhuvanchandra.dv@toradex.com" Subject: [PATCH v2] tty: serial: fsl_lpuart.c: prevent a bad shift operation Message-ID: <20200721174228.misj2mgqzcfz2lsj@pesu.pes.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kx56zhcajbwqldfb" Content-Disposition: inline User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kx56zhcajbwqldfb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable prevent a bad shift operation by verifying that the argument to fls is non zero. Reported-by: "Vabhav Sharma (OSS)" Signed-off-by: B K Karthik --- v1 -> v2: added Reported-by tag drivers/tty/serial/fsl_lpuart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuar= t.c index 7ca642249224..0cc64279cd2d 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1168,7 +1168,8 @@ static inline int lpuart_start_rx_dma(struct lpuart_p= ort *sport) * 10ms at any baud rate. */ sport->rx_dma_rng_buf_len =3D (DMA_RX_TIMEOUT * baud / bits / 1000) * 2; - sport->rx_dma_rng_buf_len =3D (1 << (fls(sport->rx_dma_rng_buf_len) - 1)); + if (sport->rx_dma_rng_buf_len !=3D 0) + sport->rx_dma_rng_buf_len =3D (1 << (fls(sport->rx_dma_rng_buf_len) - 1)= ); if (sport->rx_dma_rng_buf_len < 16) sport->rx_dma_rng_buf_len =3D 16; =20 --=20 2.20.1 --kx56zhcajbwqldfb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAEBCgAdFiEEIF+jd5Z5uS7xKTfpQZdt+T1HgiEFAl8XKQQACgkQQZdt+T1H giFRLwv/dorzPs5nBpoVYe3F6rKkcsPcUgftu5wmWsXMH7qtEsdOHt8bJ5Wsmfht BCtAyys8u14LXfoKvk5pDCq1JKJpnqSV6gNV8Mn5VYdnYAuIRJkGDj8nZjNvPLSf iQvHeyRa3rDCbSYb/eAtlPnLUwdYn+/tUYPyCQHECv/2NS6/skACNWfHftb3brdk Hhqad3BP6Og7w3T9f5eJnpQoE0tSEdP6R/wEcNXjG3SLrH/3RSI5uWW5aYOxMESy RikMQ9cFZMuuzjPaCAGn5n94mVUlw6qvtCXYq+Jxo9xVoHbR9wwBTg0B26Lj3/zY pemiPjMKcjnyHUjwFFVLVG9JkXWFM/QfmhFJZWL+AAAv6U2lFfo/TEocuAbEoMC5 UVxHWP1SbPw3frLwHZkwni8qr+Yyko+9zlwuyc8Tsc09PtXr9nWXQYF65yBgi2ZO ijZSU7go9xPFJ14+4UBvfPdPx7bKkzO/GFUu3M2ijP6geBk+6bS4EabnWMH/EiYa qFeQEn7D =RgO/ -----END PGP SIGNATURE----- --kx56zhcajbwqldfb--