Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp828521lqt; Tue, 19 Mar 2024 05:23:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWBP6NxYjPHSC6fpAwSLD8JIJuTKqLLLCahT6fbTk12Jr9HXPiOayzt5GQWM14iehw64QHd4zWV96Y8n/7YaFBfMAGMDp2pmQOWEs3Kew== X-Google-Smtp-Source: AGHT+IHjDNINOqgo6hl2VjM9+RhLyeG4fy3VvFRl01L/dq/IB6KQQi4vKBU44SfnAIike+d4FDMQ X-Received: by 2002:a17:906:364a:b0:a44:1f3:e474 with SMTP id r10-20020a170906364a00b00a4401f3e474mr1564580ejb.23.1710851007880; Tue, 19 Mar 2024 05:23:27 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d15-20020a170906040f00b00a46937bc451si3869036eja.885.2024.03.19.05.23.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 05:23:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107511-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmx.de header.s=s31663417 header.b=X955zbFj; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-107511-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 742341F2324D for ; Tue, 19 Mar 2024 12:23:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D61097FBB4; Tue, 19 Mar 2024 12:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b="X955zbFj" Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A11637F7C0; Tue, 19 Mar 2024 12:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710850990; cv=none; b=rBXZBcWMKZJroJvxIOKygBjrb7qCelP1DAaS6cFR3kz3+jAdGiLDCu+PN0BdbSFdlmc2cB2KtigjOvYIKnRw9AGxKOcQs/cpR8KY9+eEnB9lpq0XGxtKwEZ4dSYlUwKhTOLrRutawv0yhnRfYJkRcWAIEr1zB8rpBbx3F0Z8vFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710850990; c=relaxed/simple; bh=UIqUOfpSrRn0BhPFf3z0ccFmozCMz+22JZYsAzEsuqo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KAkn1ngnMfLsEL9YX+ZcJ+GDt4p3lWgTDM8ML+Nk4xZ98gNigsEV3L9ZJel2P5zG6b/MMTe2SAkPVDQJikyLgnjlpAbBCQD7ru+byds+pB+CeVElwU2vo8/mURK9BSSQ3oufS+inH7bePvoOjwTxHY+I2gZyHu9EHPSUZY50Jno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b=X955zbFj; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1710850979; x=1711455779; i=deller@gmx.de; bh=Nxw4b52QeC3UfUcGxCJ301o+Q77IyuQfrmALOSQhkYU=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=X955zbFjLAif8tQ2YyniW7mqhsUYTUA99aMHhRGlMm4HzoavRDvZ5lxLhNy1LwYf MBf7Otw6Au37NOvivIq2jnRnZPo0NcAdTe6Rb7+aoqm1hCxvhEc9Uh5VfTVJdl8/z i4cwQw1rKpMVTQm5diqOjLqplFkaJB3qplzwMxDsAFC0Zkv/tpWHgfF5PBuE0h6nr I39DvpS+KbSZPdGiGvSbju5PNzR0JrBO2pziHwcoVkW16u4fhYJphVPNO2GdXnSrd 0dgQmWfGyt8907SuTMydzapyfsXkPDDVTenJEACYZZoL0hiqKZFken0COdwIUMNmn Sa+PAUb/bzBtX7g1Fw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.8.0.6] ([78.94.87.245]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MAONX-1rbs2i0eAV-00Bt0b; Tue, 19 Mar 2024 13:22:59 +0100 Message-ID: <99a52bd5-7291-4ef6-a2b1-0fcb646dcff8@gmx.de> Date: Tue, 19 Mar 2024 13:22:57 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] fbmon: prevent division by zero in fb_videomode_from_videomode() Content-Language: en-US To: Roman Smirnov , Daniel Vetter Cc: Thomas Zimmermann , Sergey Shtylyov , Karina Yankevich , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org References: <20240319081344.7223-1-r.smirnov@omp.ru> From: Helge Deller Autocrypt: addr=deller@gmx.de; keydata= xsFNBF3Ia3MBEAD3nmWzMgQByYAWnb9cNqspnkb2GLVKzhoH2QD4eRpyDLA/3smlClbeKkWT HLnjgkbPFDmcmCz5V0Wv1mKYRClAHPCIBIJgyICqqUZo2qGmKstUx3pFAiztlXBANpRECgwJ r+8w6mkccOM9GhoPU0vMaD/UVJcJQzvrxVHO8EHS36aUkjKd6cOpdVbCt3qx8cEhCmaFEO6u CL+k5AZQoABbFQEBocZE1/lSYzaHkcHrjn4cQjc3CffXnUVYwlo8EYOtAHgMDC39s9a7S90L 69l6G73lYBD/Br5lnDPlG6dKfGFZZpQ1h8/x+Qz366Ojfq9MuuRJg7ZQpe6foiOtqwKym/zV dVvSdOOc5sHSpfwu5+BVAAyBd6hw4NddlAQUjHSRs3zJ9OfrEx2d3mIfXZ7+pMhZ7qX0Axlq Lq+B5cfLpzkPAgKn11tfXFxP+hcPHIts0bnDz4EEp+HraW+oRCH2m57Y9zhcJTOJaLw4YpTY GRUlF076vZ2Hz/xMEvIJddRGId7UXZgH9a32NDf+BUjWEZvFt1wFSW1r7zb7oGCwZMy2LI/G aHQv/N0NeFMd28z+deyxd0k1CGefHJuJcOJDVtcE1rGQ43aDhWSpXvXKDj42vFD2We6uIo9D 1VNre2+uAxFzqqf026H6cH8hin9Vnx7p3uq3Dka/Y/qmRFnKVQARAQABzRxIZWxnZSBEZWxs ZXIgPGRlbGxlckBnbXguZGU+wsGRBBMBCAA7AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEERUSCKCzZENvvPSX4Pl89BKeiRgMFAl3J1zsCGQEACgkQPl89BKeiRgNK7xAAg6kJTPje uBm9PJTUxXaoaLJFXbYdSPfXhqX/BI9Xi2VzhwC2nS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plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:HzvfooUmpaWyEE5Pay2Cw3SS8hcXQuzTUAFh8bbYWl8JwC6iW04 VF/61+Clof0FpCg28VJk89pYjvQhh0i+/6E5rSi4il7mVZEFM0PQCG709G9zY37ZS9NR9Vc x6cgfmkiEirJ1lJANz7x1PAgBZkB+NFFjygkg49S/0CP4Rn3ZRv9LGWSDlv5mVwhf7wqOrl PDfOlVCrat95QyLY029eg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:5SbLCblxnVA=;qXXF+5a8auLxRt/33p6+g3jLYHs BTqGH37DrfubIWv9lXG9fKGuPlkhwFxvvpO0pjB1RueV3KN7kchRU/AFEoQ7Nvi/K1S7EmwKO yheXXJiMALv3WohLdMWAAmg9+0q3PQSW4YYu0w16MEJYIeJGTuWL8lFroLWBmZcaQ21JhU3Zc CkUp9y3zVJl3G7mZXl77sDrSmbnK1AyDGelTxk4Lhr403Tb4fgqfo9nVATlrZLwG2qfNImVeK dp68Z8CYdrjAmUOy2yi9dzgVxjMQEvGdpBkMpKhQKHSWJxgkEOaW4Z4i9RhebnKPrYCW7rsvj UTP/PF+7WGvHWOxHyFR0O1D3FxRDv/zIusLAA4rjGw+lxT0RHXWH1xHOVMb9YLljtbtlS521e CriE+JgfN7y/7H8un2wu4S0j4bxn4b1aEQlurDJ9lOQXCM1ue9PMSoGYAh0QbxuQ597VtVm/o sMG8TggxxRpZGTz3WDqYQe1msii4Y8utUJaK3Apfe+y4vffmRc7/adXJy4Gz6OVloeFc75ZzR XjwOJn/hARTr/8u6owlxrSgkNF2k1f7wjGdt6jSh9QNMA+Z7rvZ7sLlkqdFslbxHdcUM+GIuY pFYlgdmC77BN+gnAu7stgAwZZ25pILn1OWAeM0uO7oC6rLccLFGHuO2XIuM4e9RqilwaJlbN5 pWUdnJEH4KXJf3I43EUpoWuZvqgzFcXq74QjPln0O0bup3dkHbNKPd7v04/J67rTjrOjC7MpY K4y/fDVKLknGzDIfjfV1I+hXRnrJjDK4iZ3m6HwqEiGdPEKXvPOV0chu3abZuqLIwaHIW/M+G SC3pWI2R7ZFicyZiD//UbcSnbKEqm96heIqEt0ktf132U= On 3/19/24 09:13, Roman Smirnov wrote: > The expression htotal * vtotal can have a zero value on > overflow. It is necessary to prevent division by zero like in > fb_var_to_videomode(). > > Found by Linux Verification Center (linuxtesting.org) with Svace. > > Signed-off-by: Roman Smirnov > Reviewed-by: Sergey Shtylyov > --- > V1 -> V2: Replaced the code of the first version with a check. > V2 -> V3: Replaced the code of the second version with a zero check > > drivers/video/fbdev/core/fbmon.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core= /fbmon.c > index 79e5bfbdd34c..ca946919d962 100644 > --- a/drivers/video/fbdev/core/fbmon.c > +++ b/drivers/video/fbdev/core/fbmon.c > @@ -1344,7 +1344,7 @@ int fb_videomode_from_videomode(const struct video= mode *vm, > vtotal =3D vm->vactive + vm->vfront_porch + vm->vback_porch + > vm->vsync_len; > /* prevent division by zero */ > - if (htotal && vtotal) { > + if (htotal && vtotal && (htotal * vtotal)) { > fbmode->refresh =3D vm->pixelclock / (htotal * vtotal); I modified your patch like this: .. - if (htotal && vtotal) { - fbmode->refresh =3D vm->pixelclock / (htotal * vtotal); + total =3D htotal * vtotal; + if (total) { + fbmode->refresh =3D vm->pixelclock / total; and added it to the fbdev git tree. https://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev.git/com= mit/?h=3Dfor-next Thanks, Helge