Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3703631ybv; Mon, 10 Feb 2020 05:01:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyiga0qbwvIgekHGjI6HL9ffcJRuX+irb4RE5ZMUFPpn1eHXYyd9m4kem1X/fU+b7db0HmJ X-Received: by 2002:a9d:67d7:: with SMTP id c23mr972580otn.262.1581339711854; Mon, 10 Feb 2020 05:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339711; cv=none; d=google.com; s=arc-20160816; b=MDCEZ4LNR8e4Y4UeRDkmB4ilr1ANsf5QhQfKkyJgozXd2/L830hPoJgoXkNAQ9PL+A AqXbqGZrYhl6fP7dvv07SFGyOG7PwaujeGIKgus70quv9rfYnPlov5VAJzG6Co9z4C/e gRrfaxTZ1tpY55UZGM8C0UtT8DH2tnmD+b6KKphcGFlkA6mz/XqjV8dg3xmKqcryUnrw b92FoIW1LbpbOO8ECNQiQFv6qzqc+INAEq9XEtn/TaxVnpHdcrG4IxZAlifU1Ejw1KwW e9bq8Z9Y8m8tIFyJVmwMUjE0dTaQS4BiIDrOlquv5EXqto+CbuyC8DYgIXxcXP52E3hG kJNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zzWuq/edbyIFkr0ZpzoJ4L3LZxehlkieG6a0M0GbJSw=; b=iK6Qxn9pOzpI7+amHEbqfISBQdvrzV9jFlaZEPYci3CmeBQWgAvL6PjEhvMg1IROVQ DEC5arBKL0MrbrvSxU+g4k13GmPddO/d7QKL9PnJ/hNzqTfVBkAzkb9YbFlJEScBCiu9 Scw2BnmHPoeyvNwgXBy540krMGJIqzP3gOuVB3LTkhheOWVdvLWRJzKl87/0kHOWSHsq X8oQgGEgifwMSbjpzbqWEWjPno3MDsxMq6At4XMv/Gezz7y8vFUZGdfpDcn5+T2qS+TF gWpEBUxivYeVRGnumlcw03qRcejdYQ6+cEuTbLpb+uWvqhB/Y3Ev3btXfgqzmDIevbuT AiLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s3SYkS3M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26si164567otc.6.2020.02.10.05.01.25; Mon, 10 Feb 2020 05:01:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s3SYkS3M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730193AbgBJNAS (ORCPT + 99 others); Mon, 10 Feb 2020 08:00:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:42070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbgBJMlA (ORCPT ); Mon, 10 Feb 2020 07:41:00 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BB1E20838; Mon, 10 Feb 2020 12:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338459; bh=mER//Xvie/6H/Xs1QdZ3VlSUenuLA157YBjo4JLRCJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3SYkS3MyQSRvOGtft/66WAyQn8kcVgwthUwm6HuwOxjaDMufhj/3gAAJL5anIL6t yD7oybRq9WA/ZjWgxtZdJ7AbP7t+OmhhPE4QXnAaEL4Th9E737Du+R9QkKs9PlVs/R v8ji1dnLj6r4H2lRV7wOKS4Kp2/adKK8JKneVMbA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maarten Lankhorst , Benjamin Gaignard , Daniel Vetter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Daniel Vetter Subject: [PATCH 5.5 215/367] drm/rect: Avoid division by zero Date: Mon, 10 Feb 2020 04:32:08 -0800 Message-Id: <20200210122444.083805445@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ville Syrjälä commit 433480c1afd44f3e1e664b85063d98cefeefa0ed upstream. Check for zero width/height destination rectangle in drm_rect_clip_scaled() to avoid a division by zero. Cc: stable@vger.kernel.org Fixes: f96bdf564f3e ("drm/rect: Handle rounding errors in drm_rect_clip_scaled, v3.") Cc: Maarten Lankhorst Cc: Benjamin Gaignard Cc: Daniel Vetter Testcase: igt/kms_selftest/drm_rect_clip_scaled_div_by_zero Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20191122175623.13565-2-ville.syrjala@linux.intel.com Reviewed-by: Daniel Vetter Reviewed-by: Benjamin Gaignard Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_rect.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_rect.c +++ b/drivers/gpu/drm/drm_rect.c @@ -54,7 +54,12 @@ EXPORT_SYMBOL(drm_rect_intersect); static u32 clip_scaled(u32 src, u32 dst, u32 clip) { - u64 tmp = mul_u32_u32(src, dst - clip); + u64 tmp; + + if (dst == 0) + return 0; + + tmp = mul_u32_u32(src, dst - clip); /* * Round toward 1.0 when clipping so that we don't accidentally