Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp801689pxa; Wed, 5 Aug 2020 13:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg4wGqpgTQ4HyTUl1pDUFT571zFqiIHgxLGEMucbOlkEvMkKa+uWcumPsa+FvYOOhwoCbf X-Received: by 2002:a17:906:7715:: with SMTP id q21mr965177ejm.251.1596658071898; Wed, 05 Aug 2020 13:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596658071; cv=none; d=google.com; s=arc-20160816; b=j+0FVk740cG3FQ4SJ2Zy829hIVmRjZteqzZ5B6TLAekqZqtcKc626qfNfnlsSxZbaL 94SXRF6pHpozY4jiFXjk/gkkSnYb2PTi6O2A/7wW8tEH5jldTHEfRFJIMSGyhLA38rVr gjMMYp/pFkxiGKy1+XB60kPQIn0Trip+sj3/2L0BztN4i926zw/8m1Z2T6X/LPknXk9w 3mECJCe7iQ6u/hH622wkqonVV+MN9a71x1gYp2yHnqxI5gsoh4l5dkeZXRS5g8hux/Dr xvi/G2SN0KnWMw0o4e6FUzCEAYnROUt3IcoznDodf867X3kyDhRUFo5H1itbNwQoCACZ 9YlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ibQ4dTnuuPGMhTj3MUhr5mcBZ01F/Uxr6X4VUQQIYvc=; b=sYQcPgBNlvVEmVIWsacYikQ+W8sUPtmZPOhFbzm9Jpetv3Xspo0pC8v9voprJd8Dqk ZfwOQdK91SYGkpmI5aMCeR3MNOAXFypdtHOQbs3NqBvf8ikEwIxG+Mrvqtc/KbgRVTQT XSerYPewRus2QGUSLEVL67Pgt7WM4mjUysF63mccwZ179XmNuaCJ1mVGwz0pMws/r0uF 3bAhrN1hslaicMJX1Vm4FhyuDNQKnEYFyVHNcQyeoiwHe8Z9TYRyR7FxyX5cYVyUXSKa Nd0uAVxxRCGoUgNivdD/DIQjmHUsYPNfIvZzMC9Ryyap6uVYiN3ElmC/A2jCxrUmgi3R YCTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bCxIQJw4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si1935790ejx.438.2020.08.05.13.07.29; Wed, 05 Aug 2020 13:07:51 -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=@kernel.org header.s=default header.b=bCxIQJw4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgHEUFY (ORCPT + 99 others); Wed, 5 Aug 2020 16:05:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:51078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgHEQgh (ORCPT ); Wed, 5 Aug 2020 12:36:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6E9121744; Wed, 5 Aug 2020 12:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596632170; bh=SmzHEjXJKI0Ah3FCpKvLcMIvLkMQABYGGHX0eTpxkp0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bCxIQJw4GOQ+h1x3tpCiOUo/92RnUW5K44Ue5g2BDrgjVKDIeXDdMTLRnPjibu+3M Lc+TzYJggQfzEAXArbpTLmfrvfB/Y9EwDdCS/TJ+h1PFBtf+fU8o3bsVmUfKp1RiqO ox5N7Y2xXe+uqcPy6x6U6/8b6T9WvZmByeDlqzew= Date: Wed, 5 Aug 2020 14:56:27 +0200 From: Greg Kroah-Hartman To: "Vabhav Sharma (OSS)" Cc: B K Karthik , Jiri Slaby , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhuvanchandra.dv@toradex.com" Subject: Re: [PATCH v2] tty: serial: fsl_lpuart.c: prevent a bad shift operation Message-ID: <20200805125627.GA1822283@kroah.com> References: <20200721174228.misj2mgqzcfz2lsj@pesu.pes.edu> <20200729160333.GA3652767@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 don't see how this can ever be an issue in "the real world", can you explain how it could ever be a problem? thanks, greg k-h