Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1004990pxb; Wed, 6 Apr 2022 06:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ1D/Eg8g5k+qjR2kJ3DIDhW/o21/BqVvPo36hLreIYllkPGYga9Oc2NMQcmuuk7JUFmgo X-Received: by 2002:a17:902:b488:b0:156:509c:5c42 with SMTP id y8-20020a170902b48800b00156509c5c42mr8722443plr.2.1649251906063; Wed, 06 Apr 2022 06:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649251906; cv=none; d=google.com; s=arc-20160816; b=oHccjJv7cGWTvSOeyW+H56hgJ1mNVy/DdN4Jly6CcLFNCMUKwfLNJU5V/u+SeXKq9C kYyHfAdGMeYldUi7X0DgjTj9MB2X7n/ph3ExvX0dmXVfumwldPxBmdwNEjIOaKx1nHbP GWZiKRHkf47zdiaFxoDleeEF0zFkcIjRVn29bg88PrvdTbKSr+UsznxJ0jdQcLIIvjzz V9pVaNKdSYLTYvYk1/f4IwuRRL8MvJrOxo++Mm30aFL3X+DR49U0xVmGYlZbXO+1kaeJ FpzWV2agkJ/XkBxJDseMRPWMYFnphRezY4NZHx5oZmyrrbE/FdBRtxRAMkP5RlGL0qL8 J5zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=45LB/BiICzVUDYyIrq9g2QWPTPAY3CUo4P3fTGAoCms=; b=JNMIQ92freb6qoF73PNO9ADu5CK8A/QtWeVFIZnJh7xXMNny8r19S21c15EmhNEiLu 6wwb8QKvfCsq0l+kbYJkKU3D/ppDED0lHHtJjGaatE2CyFQD6awGQGVDUTy/sQfsUKuF 0KrPzV4gkg4VAXR3vFOHf67FZ/NiJb6UXcl1/sDy0aHCMqZbjOl9qpecfb3EGCh01eCz Ewojt17z6abuJVinALi8UlLVe4a/pJTVgTZPXaSjKqK9I4eDVyqq/uJ8fygVYyvRyk0r e/kN/2YzqchovOjx7IyhX+9R9ol4wzUg9RY5irWcAfav+IyO/3E2ABLRiVUyAQEwkeEk qwfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=Wvz01Ii+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id lp5-20020a17090b4a8500b001bf040acc3dsi5311230pjb.170.2022.04.06.06.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:31:46 -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=@gmx.net header.s=badeba3b8450 header.b=Wvz01Ii+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E649340455B; Wed, 6 Apr 2022 04:10:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1846023AbiDFCC0 (ORCPT + 99 others); Tue, 5 Apr 2022 22:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573223AbiDES0C (ORCPT ); Tue, 5 Apr 2022 14:26:02 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC18C25C2; Tue, 5 Apr 2022 11:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649183036; bh=BbHRKnQGkXE3vRC9ZXCvePI8ASai72qNJqluS/WFTMA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=Wvz01Ii+4yMGjeYfKiJug3mt1CTSjAkEB+04WdMmMy3Emr2KCTcPZ6b1Jd3t4ZQyo T1+FmodmXD9ZpWRlNuMgvVMza3Z+Z8goc3X/VtURL56v+QtRxRnLLDzOQM2Evoqe24 FMmPfoX5ybXGWl3yaNP54XJvjI01KGgFhs6M0OU4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.146.134]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N1fis-1nzxWW3NVY-0121ua; Tue, 05 Apr 2022 20:23:56 +0200 Message-ID: <527a8c23-609f-5f8a-e076-a8a59da59865@gmx.de> Date: Tue, 5 Apr 2022 20:23:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: =?UTF-8?Q?Re=3a_=5bBUG=5d_fbdev=3a_i740fb=3a_Divide_error_when_?= =?UTF-8?B?4oCYdmFyLT5waXhjbG9ja+KAmSBpcyB6ZXJv?= Content-Language: en-US To: Ondrej Zary Cc: Geert Uytterhoeven , Zheyu Ma , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List References: <202204051946.43277.linux@zary.sk> From: Helge Deller In-Reply-To: <202204051946.43277.linux@zary.sk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VQ5r3yMnxqPttL/PFNGbTOfQhswQ4R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crHNQg9sUc7L+lbc5blKRSYNow/15cLaTLplcKtz/DJti3rDThrMjxh9BlPqUsrXly SllsksrROsf5YF8ppeMLDjRDGJtsl8811ihMaPdvV9Q42cw/JVTRAUejywqynsAb8fUwAfi8P qE3/nSiQBhUSvL3qKPbPu0Wh9H8fx2YQIuJTj8YqvXdr4FRgU2sYoiEFQUQ/EwyFkeBGlRFgL kHmOx2S4B2bQtrPHfmvlYC2Z+E++s2eay198hHAL0eComKwkQ3l0E0YlIwFnTcp2fC6Za+Z3i WFIg/1ON4hXwl0= X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 4/5/22 19:46, Ondrej Zary wrote: > On Tuesday 05 April 2022 08:33:57 Helge Deller wrote: >> Hello Geert, >> >> On 4/4/22 13:46, Geert Uytterhoeven wrote: >>> Hi Helge, >>> >>> On Sun, Apr 3, 2022 at 5:41 PM Helge Deller wrote: >>>> On 4/3/22 13:26, Zheyu Ma wrote: >>>>> I found a bug in the function i740fb_set_par(). >>>> >>>> Nice catch! >>>> >>>>> When the user calls the ioctl system call without setting the value = to >>>>> 'var->pixclock', the driver will throw a divide error. >>>>> >>>>> This bug occurs because the driver uses the value of 'var->pixclock' >>>>> without checking it, as the following code snippet show: >>>>> >>>>> if ((1000000 / var->pixclock) > DACSPEED8) { >>>>> dev_err(info->device, "requested pixclock %i MHz out of range >>>>> (max. %i MHz at 8bpp)\n", >>>>> 1000000 / var->pixclock, DACSPEED8); >>>>> return -EINVAL;x >>>>> } >>>>> >>>>> We can fix this by checking the value of 'var->pixclock' in the >>>>> function i740fb_check_var() similar to commit >>>>> b36b242d4b8ea178f7fd038965e3cac7f30c3f09, or we should set the lowes= t >>>>> supported value when this field is zero. >>>>> I have no idea about which solution is better. >>>> >>>> Me neither. >>>> I think a solution like commit b36b242d4b8ea178f7fd038965e3cac7f30c3f= 09 >>>> is sufficient. >>>> >>>> Note that i740fb_set_par() is called in i740fb_resume() as well. >>>> Since this doesn't comes form userspace I think adding a check for >>>> the return value there isn't necessary. >>>> >>>> Would you mind sending a patch like b36b242d4b8ea178f7fd038965e3cac7f= 30c3f09 ? >>> >>> When passed an invalid value, .check_var() is supposed to >>> round up the invalid to a valid value, if possible. >> >> I don't disagree. >> The main problem probably is: what is the next valid value? >> This needs to be analyzed on a per-driver base and ideally tested. >> Right now a division-by-zero is tiggered which is probably more worse. > > I still have an i740 card so I can test it. Good. Someone wants to come up with a proposed patch? Helge