Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp667749pxa; Wed, 5 Aug 2020 09:56:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz22xVFQvgmUk9IF/i6Ft2Up1Ub9t27+0IR528sOh+odds9pQyoJYrVVsKBQoOFUv2lvxpL X-Received: by 2002:a17:906:4094:: with SMTP id u20mr130532ejj.553.1596646609843; Wed, 05 Aug 2020 09:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596646609; cv=none; d=google.com; s=arc-20160816; b=CPPoxAP4m9Gbtisu3pNyAd7Pk+waznGqxOttU9JCIMdKIvvOx9r5T1fPhm7QUFyx7B uPSeb+pG6c9+VdwbvhUio2/wnDNS2K6rkH+J13ljaJ7hjdhf8r/Ud4w2noKIQi8DCmsz eRWcO4x3uknYRVQXTtf7vdXLwPbDyU0bCMy5Bycncj2P1Zsxe1ybcrQnuEUgEsup+7/S gwcK2mm58J0baTfAwfkR3Ojv2r007uo+HfjnwbWUnGQbEk/Ovpn4XhHrUttcstSdlNlP 5DMuZHX89V2/kxeJBf8AJkQs/lfQe24k7SbJkxd7P8BeDwYCkJ4uKOR1v1DdP0oUEjdm iccQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=a94+vY6/4IIigbXjg7NoT3QyS3gyeM3tRGM7IVe4C4A=; b=pV//Cys0Trxl3m0jMqObuJh49vupepOrCSfnxOvGs9kbfAoy9BeFuS2BFf+ukIXU0o ZXtMgOz3dLMENiY831C53HnzZmarjhRTg2Jr1ENMtoVQQRPJAv/zrYj/HiUwC9LtNn80 wm4WNVvZo0+N7ucyUqDh3Opoi9CSqYLIHE0ncz0/SVT5Q3iWVZWNEg5Rjut3+8sAI1Tp hFTorC5x5L6qvDBvoIwWcgPDk4V2aqDwERwXowAiQw011xG47l0Obtmcb3KY7EZ/XudD lOzCmbTkFOtdz9/YiZqy2Ya5lkHs9vKwLRbsGUgUqSFRufFgxNdSIx4e5BwXrh+uembw TZEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b=15Gzl4QZ; 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 x8si1561042ejs.414.2020.08.05.09.56.17; Wed, 05 Aug 2020 09:56:49 -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=15Gzl4QZ; 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 S1727985AbgHEQz5 (ORCPT + 99 others); Wed, 5 Aug 2020 12:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728232AbgHEQwo (ORCPT ); Wed, 5 Aug 2020 12:52:44 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B2FC08EA0A for ; Wed, 5 Aug 2020 06:16:28 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id w25so12174904ljo.12 for ; Wed, 05 Aug 2020 06:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pesu-pes-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a94+vY6/4IIigbXjg7NoT3QyS3gyeM3tRGM7IVe4C4A=; b=15Gzl4QZddTS7bZppiLCks8TnKdGjjThf1+1n2PB6hvFFKm0anFwj1mRbuIopHjtjZ PmhBrjQq9P0jGAtfWE0WpRv0NUlg+TC0xFMMPI0UdQ5zswvcPJgKz7zuojmmHBPoo+fM Nk0mZHL66mV47gSHqMPCmZEUVeTWLmSsOnPbETHn7F1sflFlCeHJG6lZ2ugkPeICATot 05QaAVOAxe1WcFLQn+qCP6t5k76N4waNiQE70DxT7FRmkjn2xfCFlv5kCxbeR48a6fqW uAr7zHqPvdbgmz0OpHYND8tA6Zag4e4lDHNcV8RPJwuOPO8wmk2LM8lc02XvlEKJ7Fnh gSew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a94+vY6/4IIigbXjg7NoT3QyS3gyeM3tRGM7IVe4C4A=; b=r40xh0nQUeQ+g+hA3YTt6BQ85M1JhpCRGmHIfgMy4EsozwjIy4bepp7PKu6pKsZe3O EQjdaYP6Ccy3AZZ3pEY6YDJLw27jHtcyo6BH8eCOHqUn4KZpoLM372yJThxowLNlGBY3 +z3bUhRtpn7y8zb7dKznF4YD7Y5FvSzMBlxMHgnw6bS9huongLPuBm3ECDxuvL4iHSBd iG1lX10E/i57f5c0c70z2gIlMZn9gAY8n6AykDimA9eG49tr2LlEHF0iocpzktqSp8yh InEWHifnuF43lfJUxqra+B0QkFafQ8nXxXJV9RxlOkBHIUWasMTfAvvMttRB/b6nDlnE OI4g== X-Gm-Message-State: AOAM530Tq+Ui/febeUqff2rQXaUn0sfitgZEx/P0+IovsdVU9AxQTNUV O29tGYMTvH4/NPYwBhum2dfwvz9LMGaEYdpwbVJ39w== X-Received: by 2002:a2e:9c59:: with SMTP id t25mr1397247ljj.402.1596633386436; Wed, 05 Aug 2020 06:16:26 -0700 (PDT) MIME-Version: 1.0 References: <20200721174228.misj2mgqzcfz2lsj@pesu.pes.edu> <20200729160333.GA3652767@kroah.com> <20200805125627.GA1822283@kroah.com> In-Reply-To: <20200805125627.GA1822283@kroah.com> From: B K Karthik Date: Wed, 5 Aug 2020 18:46:15 +0530 Message-ID: Subject: Re: [PATCH v2] tty: serial: fsl_lpuart.c: prevent a bad shift operation To: Greg Kroah-Hartman Cc: "Vabhav Sharma (OSS)" , Jiri Slaby , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhuvanchandra.dv@toradex.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 5, 2020 at 6:26 PM Greg Kroah-Hartman wrote: > > On Wed, Aug 05, 2020 at 12:09:34PM +0000, Vabhav Sharma (OSS) wrote: > > > > > > > -----Original Message----- > > > From: Greg Kroah-Hartman > > > Sent: Wednesday, July 29, 2020 9:34 PM > > > To: B K Karthik > > > Cc: Jiri Slaby ; linux-serial@vger.kernel.org; linux- > > > kernel@vger.kernel.org; Vabhav Sharma (OSS) > > > ; bhuvanchandra.dv@toradex.com > > > Subject: Re: [PATCH v2] tty: serial: fsl_lpuart.c: prevent a bad shift operation > > > > > > On Tue, Jul 21, 2020 at 11:12:29PM +0530, B K Karthik wrote: > > > > 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_lpuart.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_port *sport) > > > > * 10ms at any baud rate. > > > > */ > > > > sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits / > > > 1000) * 2; > > > > - sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) > > > - 1)); > > > > + if (sport->rx_dma_rng_buf_len != 0) > > > > > > How can this variable become 0? > > Condition x, taking false branch > > Explicitly returning zero > > > > static __always_inline int fls(unsigned int x) > > { > > return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; > > } > > What false branch? I'm assuming he's talking about the value after : in the ? operator. I am checking for the wrong thing in the if statement. We will have to check for the return value of fls() before performing the shift. I can change it and send a v3 if you agree. Please let me know. thanks, karthik