From patchwork Tue Apr 11 08:45:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 9676333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CCD9E60234 for ; Wed, 12 Apr 2017 01:08:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B786328565 for ; Wed, 12 Apr 2017 01:08:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC6172856B; Wed, 12 Apr 2017 01:08:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A44128573 for ; Wed, 12 Apr 2017 01:08:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 645E36E1E4; Wed, 12 Apr 2017 01:08:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 384 seconds by postgrey-1.35 at gabe; Tue, 11 Apr 2017 08:53:19 UTC Received: from dggrg02-dlp.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2AFE6E444 for ; Tue, 11 Apr 2017 08:53:19 +0000 (UTC) Received: from 172.30.72.53 (EHLO DGGEML401-HUB.china.huawei.com) ([172.30.72.53]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ALK12800; Tue, 11 Apr 2017 16:46:40 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Tue, 11 Apr 2017 16:46:17 +0800 From: Zhen Lei To: VMware Graphics , Sinclair Yeh , Thomas Hellstrom , David Airlie , DRM DRIVER , linux-kernel Subject: [PATCH 1/1] drm/vmwgfx: remove an unnecessary check Date: Tue, 11 Apr 2017 16:45:48 +0800 Message-ID: <1491900348-16352-1-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.58EC97F1.00DE, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3658030ba1894c6bd674374e62f41329 X-Mailman-Approved-At: Wed, 12 Apr 2017 01:08:13 +0000 Cc: Xinwei Hu , Zhen Lei , Zefan Li , Hanjun Guo , Tianhong Ding X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP commit e7e11f995642 ("drm/vmwgfx: fix integer overflow in vmw_surface_define_ioctl()") ensures that each req->mip_levels[i] <= DRM_VMW_MAX_MIP_LEVELS, It would be easy to conclude that the sum of req->mip_levels[i] (i = 0, ..., DRM_VMW_MAX_SURFACE_FACES - 1) is less than or equal to (DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS). Signed-off-by: Zhen Lei --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.5.0 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 05fa092..4520b1f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -719,8 +719,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, num_sizes += req->mip_levels[i]; } - if (num_sizes > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS || - num_sizes == 0) + if (num_sizes == 0) return -EINVAL; size = vmw_user_surface_size + 128 +