Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3437211pxb; Mon, 4 Apr 2022 17:00:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdbZ04N9usVWZ2Pmde+EhnWF94dHcSWQB/5tbJo5S0kgZeyX8NkqYgmqRZjsTpC4t76jJm X-Received: by 2002:a05:6a00:188f:b0:4fa:ece9:15d9 with SMTP id x15-20020a056a00188f00b004faece915d9mr698279pfh.28.1649116833074; Mon, 04 Apr 2022 17:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649116833; cv=none; d=google.com; s=arc-20160816; b=yziycDEPVRWWfTs9Vnu+2D8pLD0PNYuCDSl9kuBTuyEm44xSreK6vw9SSH+c4yfzZN xcox3QX0p82JR5QplVnC9o8bYDQERSePUrEtCZuL/Zg2hYpwKe/xHLqOSYxQzUv6E5R+ XWA/lFCQO0EGDi54lVHy6gfWY0r90kayX/xM1UPs6g4W/NVKjMLsM4FGBtsK0Ding36T zKqMYPyXGxbFKb14K9+h926PZa9Xgc3o8gk3VZlt39li5gU89o5CqHAIjJhpAdUR5AUd hWiQLYqX01eYl0JOkLothmSk/U7xZigYzeqa1jb6a+BQxOLYqSRDv5yAL3eaWFhOKnu4 BAZQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6lQXVT/uUsnfVE8WcNYNQC83df5wSK/7H6QlhzyGSpQ=; b=qtuuXsQvsDTReEUBYUSyqAb8MnGJhqp+fNTUgzKeDjjZaNPRYmOmF2cid86GtDobpJ 6CCm5jE5rTgZSPiSBbcSP8iS/6ax0aaV/np6xba1WUCv+e81q6U51NP8Hj13mhAzuyQm QkuV2i1ZvGbk00ionYSv3wEOSBCHMXS7q+u1IORQjSO05Fb0UPF3TSDLFiHgiAHp/roY D70BNMcOeXhQMKDq4r8QqegjRKO/mZ65cnU3T/WfjXpHODnDRJ2oZQIqiqJb9sj1ktXV 8ywzGSXv4rjH6oCflpKGqRhy+TBqkmGbR8m7UCbrDBhijX9pJOcXzzDu0Ko92L62qSB1 vmtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KHLiQpb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q65-20020a632a44000000b003816043efa1si10957825pgq.406.2022.04.04.17.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KHLiQpb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A6FED89; Mon, 4 Apr 2022 16:38:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242327AbiDDIuL (ORCPT + 99 others); Mon, 4 Apr 2022 04:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241883AbiDDItq (ORCPT ); Mon, 4 Apr 2022 04:49:46 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFA93BA5F; Mon, 4 Apr 2022 01:47:51 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id o10so1663154ple.7; Mon, 04 Apr 2022 01:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6lQXVT/uUsnfVE8WcNYNQC83df5wSK/7H6QlhzyGSpQ=; b=KHLiQpb41/Jw+rhklJELDpaMOhckeHIcsw9AtQfrQZVhXUpiSvQOoEqLOWnWZt5N1z fvw5nL32fYw19ijPqYbuxD1CKpEfwJ5AWt/SVteFr4bVvwv6VdXylzhAcHNAJ2DDNUoD uJYWZuWDo3vo/IlAuNirkKPlaCiPaYIxYxkT6R1KdmrLjESBZ8q1NViVRwLfWSDjIaJ1 zHy5Alslrx8QGBPFt4DtgHTz7U+DYAGT0DlpOpDG4CIRSZnMFJxfQ1HxmLAHtuNWexeX KsPVNi1JlUl1f0C3+1/nq7L4cfl9ib7E3+w4a5wLnn86lSz0M+PNAdC0Jm3TUXKx2Yc3 IyYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6lQXVT/uUsnfVE8WcNYNQC83df5wSK/7H6QlhzyGSpQ=; b=4q1Pj6gP3mQJAmitA3+OVSu8pkvIAYXQv3mRT9gSdrO7sOTOV6XuojrLW8mkHL3/UZ SKXj8it6iHnMV3tSZ6FIMQehDDbYKKQA9l/tNDv504I3l41wRX7Ddzfay4oYVzVpZz3Z RvFRjmSqayWUYhhAVmWXKUjuFs6yMcr9KcsMZNPHjzdHgAsqiJk79U7ECkFUgkt/ky49 nMeR8jd1UkzJhZjZKFRHFcFJOi5YKSHi3slztLZCcBz9fSXaygzXpN1jaj1CVXYJ4Z62 G0kjav7U0RxF0IJ094+Hy/Cfewm/VsOTAgjm/duqH9EOk+jDB34ZFlrRJrYIBtY38uZI 9QKg== X-Gm-Message-State: AOAM532KeJwK1H12LxHiv99s2Y2GAXc/cjqOICd/0tPw0cIZ1Ey5Vjcb CcZuYiI9MyRET2mRMKkZzw== X-Received: by 2002:a17:902:7887:b0:156:788a:56d1 with SMTP id q7-20020a170902788700b00156788a56d1mr10208376pll.110.1649062070526; Mon, 04 Apr 2022 01:47:50 -0700 (PDT) Received: from localhost.localdomain ([144.202.91.207]) by smtp.gmail.com with ESMTPSA id u6-20020a17090a3fc600b001ca88b0bdfesm3991960pjm.13.2022.04.04.01.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 01:47:50 -0700 (PDT) From: Zheyu Ma To: deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zheyu Ma Subject: [PATCH 2/7] video: fbdev: neofb: Fix the check of 'var->pixclock' Date: Mon, 4 Apr 2022 16:47:18 +0800 Message-Id: <20220404084723.79089-3-zheyuma97@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220404084723.79089-1-zheyuma97@gmail.com> References: <20220404084723.79089-1-zheyuma97@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 The previous check against 'var->pixclock' doesn't return -EINVAL when it equals zero, but the driver uses it again, causing the divide error. Fix this by returning when 'var->pixclock' is zero. The following log reveals it: [ 49.704574] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 49.704593] RIP: 0010:neofb_set_par+0x190f/0x49a0 [ 49.704635] Call Trace: [ 49.704636] [ 49.704650] fb_set_var+0x604/0xeb0 [ 49.704702] do_fb_ioctl+0x234/0x670 [ 49.704745] fb_ioctl+0xdd/0x130 [ 49.704753] do_syscall_64+0x3b/0x90 Signed-off-by: Zheyu Ma --- drivers/video/fbdev/neofb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 966df2a07360..28d32cbf496b 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -585,7 +585,7 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) DBG("neofb_check_var"); - if (var->pixclock && PICOS2KHZ(var->pixclock) > par->maxClock) + if (!var->pixclock || PICOS2KHZ(var->pixclock) > par->maxClock) return -EINVAL; /* Is the mode larger than the LCD panel? */ -- 2.25.1