Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3426038pxy; Mon, 26 Apr 2021 01:10:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk+OOxZ8RrwrXT9tApIEqNz9AnWHLuFuLIljiIhS6xYZuLLCCcv8ZFS9qMK8but9SnyoJl X-Received: by 2002:a17:906:9598:: with SMTP id r24mr3677192ejx.57.1619424639171; Mon, 26 Apr 2021 01:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619424639; cv=none; d=google.com; s=arc-20160816; b=ttiKGc7wFon+TzKYQ2m22qYNESZcWsQUBqQyQ8yGuQvgpt5Qd8fs0aMs4irk9zFXOz V3DNf+7Lnqd7iLN95pB9fXhQDYyx8vmS9rwgaQudRkvMS4tV3zIB9+6ny3B7dXGSQOId iuc9yWd1ygKzzgEQJXaHZ4B/uz4ptCnfVHWTRyOPywfkaX+tUnnWf3+LmYHcFt8gnhqN QTyPnSa0hYePlpRKSBE6Ku9i7LqPlKqRNCZGWGf1eHhTt3zESNQpl/3LwZMtnhCxjzXH Cjqoj358Dx/c5FcOQLd+cWFNyKTFEyvHVZLm9yRw8r7/77EVPDHe3G8QY08S5r2jmqDt F6Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bjPt5FUACxtGcupZ/AywWb7TYyJ6n7OGtUNGiFpcRGI=; b=wRahIBM7oKCNa8xmATnQBj+wwkZ24Q5gqMGdushRxChasPGVPG4RgMqLD5DWVDjRzq VWX4gjlM007fy0w6KcNZvcruZ+AoYL0WGVhMJo8s+4xyknLt2Kj9zD8sn29He5HKfeIr 5o6ZnrxSoPi+68ewjHtnaD1/v5M6HwMS0dLnkwxMsAC2ATrNYnTUS381Ry5Zd70PiDzC CXjjVXJi4DawgqfYHUX4pbBJpevPvDpHQTNgIq4s3lVP/ly9wS//SELIXCcCf0xD5JvD Xg3jdiJqeqIHF18BxYus8HUZoiPXdL7mYDzJESADNDQwPZ3VxryMf172MeKeYkkGHQaZ B5MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jk8u5CJ9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si13534041edw.35.2021.04.26.01.10.15; Mon, 26 Apr 2021 01:10:39 -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=@linuxfoundation.org header.s=korg header.b=jk8u5CJ9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbhDZIJR (ORCPT + 99 others); Mon, 26 Apr 2021 04:09:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:54904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbhDZIJP (ORCPT ); Mon, 26 Apr 2021 04:09:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B22C661075; Mon, 26 Apr 2021 08:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619424513; bh=/sO2t0hU88ihYrgppTs+DSbTAXvGpptkwOt7IzR76uE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jk8u5CJ9jK8F1AgHr9yS7fAuZvZIBF1VnI0xl9JMRZ7AG9RzX0T5jr4M8WfPgi+uP 03QS86rcI9mLsu8Do/LTvzrl1fK3h5KG3d4XVAvYZQzEycoNl6ghTdjgtEDZxhNiZa OxrVoPfuYaZEn58pXsC23q9l1GUSwtV6oQ+g8AkU= Date: Mon, 26 Apr 2021 10:08:30 +0200 From: Greg KH To: Sherry Sun Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: Re: [PATCH 1/2] tty: serial: fsl_lpuart: fix the potential bug of division or modulo by zero Message-ID: References: <20210426074935.11131-1-sherry.sun@nxp.com> <20210426074935.11131-2-sherry.sun@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210426074935.11131-2-sherry.sun@nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 26, 2021 at 03:49:34PM +0800, Sherry Sun wrote: > This issue is reported by Coverity Check. > In lpuart32_console_get_options, division or modulo by zero may results > in undefined behavior. > > Signed-off-by: Sherry Sun > --- > drivers/tty/serial/fsl_lpuart.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c > index 794035041744..777d54b593f8 100644 > --- a/drivers/tty/serial/fsl_lpuart.c > +++ b/drivers/tty/serial/fsl_lpuart.c > @@ -2414,6 +2414,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud, > > bd = lpuart32_read(&sport->port, UARTBAUD); > bd &= UARTBAUD_SBR_MASK; > + if (!bd) > + return; How can this ever happen? Not to say this is a bad check, but it feels like this can't really happen in real life, what code patch could create this result? And have you tested this on real hardware? thanks, greg k-h