Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1505425rdg; Sat, 14 Oct 2023 05:15:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFy4K17tVeQzQ4jhL0ghYZ5gNOonXz/0ZNG1wEJfcfRpvzSb06396pY7b7+Tzr1Gg9hbBC6 X-Received: by 2002:a17:902:c40a:b0:1c7:5a63:43bb with SMTP id k10-20020a170902c40a00b001c75a6343bbmr36303355plk.8.1697285758518; Sat, 14 Oct 2023 05:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697285758; cv=none; d=google.com; s=arc-20160816; b=XZXaRWpYDxdF4lS1ji1JB57d1QOEX/eKFR8XuZxI3lupOMtMCr6WmmSO3yp20PqleS 2TXjaI0bLFSMZT4ueKziSfhYMkv+oCbPUZaJgd7G8Mrul/kX1+t/0pBPwP0n9LOivBDV Im3QNHUnoSBpUmOsZBdNY/9TgN7u10ffOHA27yR7G5+qq1VSyjXa0sd8+1UiMXm/sFy/ vQSMK6HjmMa6qWVJ/CHA33qfUhqBcWIyCEiGt1csvyH8BirZ/qAYd1ljGNlWj9F08Rvx U+zQ09FIIu3MeK8bsTdt1KA/9mS/fiumKn07FNeLb5mMOwdOSSMHv6doxTqDEChi/yib LYyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:cc:to:from:message-id:dkim-signature; bh=YQheIxJjOau1s9uk+wO2dkdpHL1+wExdCD1+23pg5Oc=; fh=Ep+lkDbW+5Y+SoJG9Ec3S3Y7NAp85MfybPNQcEddV1k=; b=eOkajJN8Dn7BgWj654Tb7tVtRxJFflBKo0Prk+0tTnFChI3GLf6xeNRVOhK3DNllW9 WsFcFudi93fTgpI8ytCqYfQ1tC5A37zKTNF3P+hGilmJrBU4jUHPLgSCojhZH7flwEyN /ui+o96ORL8R8h26V3B8GJ8Bj1WnNAKbtWA4Dps/YN+L5Imoc1x21Qs8kF7u/Y56zzFk ib586ff0RMH9kyESSPtYaHA7VvLnF8wm3BazfYE1EI6MuaRX3NjlTmkcrKPUUTNTfBDN i6zpb1SQX+RkD0E3HVE25jmJY5o3Twk9dJJV3FA1xIovlAJyKye6qHORPB2jKi2vaGUE Tnvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=aHgkbvsT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w2-20020a170902e88200b001c9ad30e4b8si7121442plg.320.2023.10.14.05.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 05:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=aHgkbvsT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7C906808E564; Sat, 14 Oct 2023 05:15:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233194AbjJNMPC (ORCPT + 99 others); Sat, 14 Oct 2023 08:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbjJNMPB (ORCPT ); Sat, 14 Oct 2023 08:15:01 -0400 Received: from out203-205-221-240.mail.qq.com (out203-205-221-240.mail.qq.com [203.205.221.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929C9A9 for ; Sat, 14 Oct 2023 05:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1697285697; bh=YQheIxJjOau1s9uk+wO2dkdpHL1+wExdCD1+23pg5Oc=; h=From:To:Cc:Subject:Date; b=aHgkbvsTX81K37sYgwyGDW1oDVk/2Hm/y3Stw7Y6MIqA0MuOafDWaaxHYZZ8iKC/q bTTKm4qU/E5AzIRC452sJn+FmUX9G8UuA+Ji80DIIVgBgGSrhJK8EjokFoCqO4QOnj S7q6+2OFjczStaEMvvQdQqu+Ut+xv0AqUJAojzyk= Received: from KernelDevBox.byted.org ([180.184.49.4]) by newxmesmtplogicsvrszb9-0.qq.com (NewEsmtp) with SMTP id 3B6A8E9A; Sat, 14 Oct 2023 20:14:54 +0800 X-QQ-mid: xmsmtpt1697285694tghy4mbab Message-ID: X-QQ-XMAILINFO: OGEC8BYa7lsBWWZ/vEd4TQyQV9TARh6WvGGkSsO7/3IuF9yTmPnEUCQIn8ey2z F64IQTFMZP37lymHUS6B2HZo4knNaarGV2AJKI0/yTUoLqfNF4afRuhhV4FTNaoSbeWeTktBa01p JD4VwXJudoABheJBhAln465jjNlbz+PN6oeSO6JNDmPskkFClQDABviiDTBWrUidCOn/iR6SKVep 7P9tbTQhjAEBati0PEr7KJd0GzpWhIerLX/BtXOXLvC+fTwkCfM/Hj5SgJp9yum/bb1Qznc1tjE6 3tMx7ExLXY1y821ipYkuuelfpdP31zq/zL3ipJuYIxBBHuGaWnnPq++I8dYdCV/Ture6ssLqk9qC qcCXEO9lC+0o5c68yDTu7NMukeKRl1O04UQQC2cA8N9Kr2qFbphyC1HIieIeJ6IfywqBlXKajofI O2x5CIeWnDQh+ONXQVm8VaB+Gt3U57AncYVPzbSHGuo/sRxPzwOyHT2IcqQmNtTv4iUqMme0TEl/ CuZ63UASKrVN7Ylw6O/N2yqTpEdXvUyAk5RQRMBU1FdfIY3Wa6eHYSWxzgK3VMt9AVTkjt2FDT2w 1encBQgxY5THYl1runLZR1+trSAJvHQiZ8gtGSJwmy5ole1jRD60lrSLrsoAzJcweW5jFIfEvVJ2 quMcPFQzMVZiEOpGHUgrbsVbM2lpYXNPYT0TNGcZbowROSBnw/gEqK6XoY1SquAj0S2SGZrFnVEh rj+wdVDzIkbrNbojMWEv1G1JkWvt6gsdIWZZgCvkltWD8U/OdcOyRHnlgbJJncplq2uVO/sjNeul fw5AvqlFOJUW1rebBiLRw9F+xJy49ZA5xYdVZqEND1+p2VWkBEHCSzw9E8e8cr0ppCgKhdMAFmBm ymULOurlgBRfIeZKtH6SY/6KRUEsomydJTRfpNl5zmUjj40C0xNJ5k0SD1JQKkT6qgAH/po+Q1rP cfaacsbGI0CrhReW36tO2u3h4ZBtlznK+ZlUdGM6Ok9boHcJb3JuvvMCpr0qOVHOq3AyYnD1RGzF 0YUZGzbA== X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Zhang Shurong To: daniel@ffwll.ch Cc: deller@gmx.de, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zhang Shurong Subject: [PATCH] fbdev: fbmon: fix potential divide error in fb_validate_mode Date: Sat, 14 Oct 2023 20:14:53 +0800 X-OQ-MSGID: <20231014121453.3034941-1-zhang_shurong@foxmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 14 Oct 2023 05:15:32 -0700 (PDT) We can easily use FBIOPUT_VSCREENINFO set fb_var_screeninfo, so it's possible for a divide by zero error to occur. Fix this by making sure the divisor is non-zero before the computation. Signed-off-by: Zhang Shurong --- drivers/video/fbdev/core/fbmon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 79e5bfbdd34c..bdd15b8e3a71 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -1470,6 +1470,9 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info) if (var->vmode & FB_VMODE_DOUBLE) vtotal *= 2; + if (!htotal || !vtotal) + return -EINVAL; + hfreq = pixclock/htotal; hfreq = (hfreq + 500) / 1000 * 1000; -- 2.30.2