From patchwork Wed Mar 15 09:22:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Chen X-Patchwork-Id: 70093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2230670wrd; Wed, 15 Mar 2023 02:46:22 -0700 (PDT) X-Google-Smtp-Source: AK7set+9F+V8cO/0HKKALce5+6YxKcFVHGIziXdhsLVBE4q9MKwa4FsBaEo/MM/T0ODYahaRdfCL X-Received: by 2002:a17:902:d486:b0:19c:a866:6a76 with SMTP id c6-20020a170902d48600b0019ca8666a76mr2197190plg.42.1678873582436; Wed, 15 Mar 2023 02:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678873582; cv=none; d=google.com; s=arc-20160816; b=GcybsrCimMOkZoPqomF1XaqrBzIxfVqT9GRumwo69Bo9cUtR8IjCWBYU7mBq8Xfwh0 vuOcYf1u2eDd4ZmmFWlisNVDsmg3mf9WfPFfF+X2sc4PWDQoDElzDVhohoKcAM3JUncV 866qcX8v1Jo8Uw8BG5kDF9jToLHwygMZnRWbTEuCCytSB7VFM7j8hy+/wGzl/0vmkCaO Wc981FOG8NdBwx0fg8qpKzqOVtX4qEtkKHjUEXmrK/dVvv8EqYILb+6NenVBHGHP3SeL DDNzBJgAE/gLs/kPe8m66p+2uzg39uwgWW6/d1pYub6Y+gad0voV6lKcw8UHipwWswzj weYQ== 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=YIlDmOhHfzUv00AnBDlY+LrTEjW0fV7JmMX/NObYM/0=; b=keA7LnV+jxYTn0nDKjqmKZt99m+qeQgyCzr3k3aVi7VA4DQWGvy+OUW7+uVmPrINzF Ohiv0E7zA71e+Hi1eM6+jvjXS5cuHQpF4y6n8E9ICUD/Eu5UB7fGwGSpnFDZr8KRyJUF GtyWr17GD9qACdVYQPRtMlwuuhmKltw1uAKic7PFpDKmK24GcTzvU9xgw+GOWgPJfGTY enDJq0KwAndqTRa2jvky1yqOuHvGXHJeJGfn5NB5UpJHJRDGLlvuiI/x2fWrmJDBDzdn q/i1bnpve0fgQj76xg6SWodw2NL8+0R6bx4ikUrpR14c0h8PbFyFex9aHlcsmMEbZgds 7s/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jMwS04iE; 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 jj13-20020a170903048d00b001a180df91besi191396plb.32.2023.03.15.02.46.07; Wed, 15 Mar 2023 02:46:22 -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=jMwS04iE; 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 S231641AbjCOJXN (ORCPT + 99 others); Wed, 15 Mar 2023 05:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjCOJXH (ORCPT ); Wed, 15 Mar 2023 05:23:07 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3826A23316; Wed, 15 Mar 2023 02:23:06 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-17683b570b8so20251273fac.13; Wed, 15 Mar 2023 02:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678872185; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YIlDmOhHfzUv00AnBDlY+LrTEjW0fV7JmMX/NObYM/0=; b=jMwS04iE8sVc508yTw9rVt892u9Rx8nIWzDE5QGMJFsTaUDANTrUlNIsCG6yP5o3pu LDq2LfysPHaMkjGL3j9ODWL1DA3syFL55sDXFj70tGRHmR6FlSiD87AkrDjb3TPJqvjH NyvgT/ZmlxD/mplejH8J3tRK9SroSe/gXIiUXr4kjiN6w3+4Js+9XZjU4XRY1TGZtfC1 V/xY2lkfNuaU6Xzsb1UT4vH9MPGKqL5KAkCNxKTSgucGvV3ratbp1Bn1e8d04rpmfE5j V49tuMg/Be72TYhgkZymUVkjjrEPICEUok0rFpXWcTx1OGVG8kIQctvpTa934wxhR7Bt nlVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678872185; 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=YIlDmOhHfzUv00AnBDlY+LrTEjW0fV7JmMX/NObYM/0=; b=gIKUIOQziX+Bz1UmAvZXa6PyuqTOniZxiM4fYUfghOWML3TRanmMuRRXc05naYmeJG Vc22KcyWcUEQh0TzsQs7asFkx5feTdGj62WDrpwvjCEOAeohxQKLjXFESQYOPxOKcWyn F4KcuM2vsjiUcuXku0Y+1DBOG/tZ/t4sLWnqmSViPvQsWwd6IHBD0Xh6hoTailx7aC1R BdzR2LiNWFXSldLGMiZwPVt9ob9AiGI5DxXq9J2Koj5GBhRqPO1Q2nBFW2hAGiEJFxHB U78yTESruFn/fhlO1d0gdYT57C+MDyh1eRf5vpokQJ535fxVfJLq0OIVHQoA+/YQ79C6 R55g== X-Gm-Message-State: AO0yUKXC9nIaXvxw7swIpef2iG7GeJEb5zQckBJbQg9Wj2RW51xVHbKP qlHhK6wHwyQLvO/JokV2RN8= X-Received: by 2002:a05:6870:a446:b0:17a:c38e:823f with SMTP id n6-20020a056870a44600b0017ac38e823fmr1205376oal.51.1678872185553; Wed, 15 Mar 2023 02:23:05 -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-20020a056870e28500b00176209a6d6asm2037335oad.10.2023.03.15.02.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 02:23:05 -0700 (PDT) From: Wei Chen To: deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Wei Chen Subject: [PATCH] fbdev: au1200fb: Fix potential divide by zero Date: Wed, 15 Mar 2023 09:22:54 +0000 Message-Id: <20230315092254.1042615-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?1760426545313659975?= X-GMAIL-MSGID: =?utf-8?q?1760426545313659975?= var->pixclock can be assigned to zero by user. Without proper check, divide by zero would occur when invoking macro PICOS2KHZ in au1200fb_fb_check_var. Error out if var->pixclock is zero. Signed-off-by: Wei Chen --- drivers/video/fbdev/au1200fb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c index 81c315454428..b6b22fa4a8a0 100644 --- a/drivers/video/fbdev/au1200fb.c +++ b/drivers/video/fbdev/au1200fb.c @@ -1040,6 +1040,9 @@ static int au1200fb_fb_check_var(struct fb_var_screeninfo *var, u32 pixclock; int screen_size, plane; + if (!var->pixclock) + return -EINVAL; + plane = fbdev->plane; /* Make sure that the mode respect all LCD controller and