From patchwork Wed Mar 15 08:33:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Chen X-Patchwork-Id: 70076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2214459wrd; Wed, 15 Mar 2023 02:00:55 -0700 (PDT) X-Google-Smtp-Source: AK7set8/JCEYibAIqUaSutB7tCv01lfKcpRbtjkIKEZ1TSZwL/xvFcrEbqEbkh8HZrFAmU/Xr9O9 X-Received: by 2002:a17:902:ecc7:b0:19e:8688:86fe with SMTP id a7-20020a170902ecc700b0019e868886femr2328533plh.42.1678870854970; Wed, 15 Mar 2023 02:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678870854; cv=none; d=google.com; s=arc-20160816; b=q4B+YYnkxD4Zn2K3P0enX9h+LjDZayhhvlSjhcCrJhAQE8eGBx6jBVSCKSXF5Byr6t y8flh6+FEDJzMXNzQ+CoCdX4iswv4uwhZPdnANiC7aTriL3RSeP4zXiOno9fQHDc5yVl 1+2CUEAJMsVhf2SFJlp+H9XcFNViulIJ2Mike4jK3NxBu3B+sCwDl0mJZ4HZFLCLyb9f k3N3+HXUF9sIQ5linpPps6myMxR++CIDsYWTOTaQweSOyB/RRSF90ilGPKqKIDPGosQr 7AInPLGpLBCKRLx9Um3sgz3RYqO/hSX8wfVzcMvieCHPem7wqAvP7z4b1OCLB6GFtnqG QqTA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=vjMnP/a9aE6vyFsbxsfjUFQh+LON6M/20fpKlSvWjvs=; b=bXDin2I51vURZTwWh6vdOwWk57dwTYTIl3pEErvoMS9chsi0iHv5oG314d0VJyPteN J95JcpaXowmYJvYlV3Z7BEy99h6yk+vQgONiDuLAHAsCrFI08AyifTBafWq73Yz+m5DN lw42SJ6rB/A9orRUt9RJZokmyBaGlRbzseI6uyoJhOH3a3pRLj88BBtiKcq+WHV9yQCI GpUpmWS8rEVfMwlCqjQCEKKcWwliATKDzVPW08cCqsUb3XWZ9kKX+h6km2JdnSkyBG1Q CVcKXWIj2sAgHAV7A1/XPFMnMD+CKAlO9WmqCntG96ndASpgLitXnR49XLlEIrLkeg8K Mgdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AAjWq+87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a170902b49600b0019ca7d69673si4649048plr.196.2023.03.15.02.00.39; Wed, 15 Mar 2023 02:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AAjWq+87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbjCOIeG (ORCPT + 99 others); Wed, 15 Mar 2023 04:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjCOIeC (ORCPT ); Wed, 15 Mar 2023 04:34:02 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C43584B7; Wed, 15 Mar 2023 01:33:55 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-17aaa51a911so4807023fac.5; Wed, 15 Mar 2023 01:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678869234; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vjMnP/a9aE6vyFsbxsfjUFQh+LON6M/20fpKlSvWjvs=; b=AAjWq+87+CG048djRPbLX77rjes8Zbq1a+RYd1kDlwqFW4av+0b+qQa4U/FlQshlPR NZRi9A/+Irw42gk4glZZ+oMbYDy+JwRJM3rLrTZUdrCXFVBGuhWdmiS+d7vJOoNNWLT2 M+xHGXvDonJFaqRQEfWW/9V9o8aci3bIj8L/2xGXkxDRmrtxV5dfM2y7C/BnDyACPvKw /Deqm3OEl+bqJXELHYbFyA0/I2VNQtIBtYKvUv9ZfKAqdHkqH9tXdBMlo80q5zR8JXBP WiXdRZcTmCnO22eKTqBIc0vSZtIcoqU9ydX7xRRzA1A/Pi17VBexPzpEJWms6168JnBe 5aeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678869234; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vjMnP/a9aE6vyFsbxsfjUFQh+LON6M/20fpKlSvWjvs=; b=J5R5j2wJAnsx1T4wnGNuhAEeRGqzRePxyHjmSaxvXlvmvz18CRM7C1r4rpwnK8+Jl+ VHP+K77LpMWoIy0WtOr4aN/gdj9C7cWA5F7+PN/nFF/8qmMV6uiOHix2OkQ+3bGFBfjW FIS99EHiFwqGt1KXYDz2HLuPTRVW49EUIVMDSZVxv26l4AP33VB5XjETdJ7eni/h1whk /Q9a6T0x9RzzPTMEX4t3vAW1farvmYBTJ7PCCuE3qymn4SytFPOHKCKHdm51ASr+j7Lw 7pvX8kkPTMeFXeEok96URIWC8EUHS9x3V0eJlw0MI+zlVuhm9i/Ol5/DhQ70lNqeQPVO WHMA== X-Gm-Message-State: AO0yUKWKeLLRfT1zLmqHcCFl6tQzHQR2KaVDqhhh9cmTE0rkqSJaZr9O OiwBvt0LkQw4vymw+NncnR0= X-Received: by 2002:a05:6870:6025:b0:17a:6788:e8b8 with SMTP id t37-20020a056870602500b0017a6788e8b8mr3904321oaa.51.1678869234187; Wed, 15 Mar 2023 01:33:54 -0700 (PDT) Received: from chcpu13.cse.ust.hk (191host119.mobilenet.cse.ust.hk. [143.89.191.119]) by smtp.gmail.com with ESMTPSA id v5-20020a056870e28500b00176209a6d6asm2006912oad.10.2023.03.15.01.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 01:33:53 -0700 (PDT) From: Wei Chen To: mbroemme@libmpq.org Cc: deller@gmx.de, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Chen Subject: [PATCH] fbdev: intelfb: Fix potential divide by zero Date: Wed, 15 Mar 2023 08:33:47 +0000 Message-Id: <20230315083347.3852851-1-harperchen1110@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760423685577002882?= X-GMAIL-MSGID: =?utf-8?q?1760423685577002882?= Variable var->pixclock is controlled by user and can be assigned to zero. Without proper check, divide by zero would occur in intelfbhw_validate_mode and intelfbhw_mode_to_hw. Error out if var->pixclock is zero. Signed-off-by: Wei Chen --- drivers/video/fbdev/intelfb/intelfbdrv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 0a9e5067b201..a81095b2b1ea 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -1222,6 +1222,9 @@ static int intelfb_check_var(struct fb_var_screeninfo *var, dinfo = GET_DINFO(info); + if (!var->pixclock) + return -EINVAL; + /* update the pitch */ if (intelfbhw_validate_mode(dinfo, var) != 0) return -EINVAL;