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: 97223 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1709182qgd; Tue, 11 Apr 2017 01:46:50 -0700 (PDT) X-Received: by 10.84.128.66 with SMTP id 60mr40632232pla.132.1491900410394; Tue, 11 Apr 2017 01:46:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t65si16163294pgb.336.2017.04.11.01.46.50; Tue, 11 Apr 2017 01:46:50 -0700 (PDT) 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; 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 S1754183AbdDKIqq (ORCPT + 23 others); Tue, 11 Apr 2017 04:46:46 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:5358 "EHLO dggrg02-dlp.huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751531AbdDKIqo (ORCPT ); Tue, 11 Apr 2017 04:46:44 -0400 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 CC: Zefan Li , Xinwei Hu , "Tianhong Ding" , Hanjun Guo , Zhen Lei 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 +