From patchwork Tue Oct 9 19:56:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 1571311 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id A7CD43FE80 for ; Tue, 9 Oct 2012 20:00:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68CF1A09CB for ; Tue, 9 Oct 2012 13:00:59 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yh0-f49.google.com (mail-yh0-f49.google.com [209.85.213.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 16781A09C2 for ; Tue, 9 Oct 2012 13:00:41 -0700 (PDT) Received: by mail-yh0-f49.google.com with SMTP id j52so1372687yhj.36 for ; Tue, 09 Oct 2012 13:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=8ZxW7DD9su6NDIXx6hg3p6kkCAeQGCeeZ2y1bTA8fNI=; b=n+Z8K/hsVAPRf3j8nrc3q98DkIlbc2cuhfeH2Db8Ny294KMlZ5GN3LvX8Bo6v+BfBE 5iVABFkG9DS7ZdYlLsBws/K4JjQhCz6uO/wdY0GZB8Qxtwk8AmQUofizV976USAkrY+5 Byvy+2M1qEVkJKl4HlY7fs8cnRMrEbZhH68XOE5SdmLBw/CouTeA1TR+1aKT9xajtA1M lKxygyG0WErNIzu582nO0TuQn1CdZChUZ4PzjiLqYHi1p6XF8qGX9yI/MBwv5ZXQ8Ea6 Wpq+YI3oANbNuhd2xtEGZJW4XmZi61RabG9br/G0qf7RlR77iRHjCAX+5nSLqAyLf8/E oPPA== Received: by 10.101.10.28 with SMTP id n28mr6439528ani.5.1349812840600; Tue, 09 Oct 2012 13:00:40 -0700 (PDT) Received: from localhost.localdomain (200.188.217.18.dedicated.neoviatelecom.com.br. [200.188.217.18]) by mx.google.com with ESMTPS id u12sm20609877ank.18.2012.10.09.13.00.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Oct 2012 13:00:39 -0700 (PDT) From: Rodrigo Vivi To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: avoid passing null pointer to memset Date: Tue, 9 Oct 2012 16:56:58 -0300 Message-Id: <1349812618-11518-1-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349805046-4587-1-git-send-email-rodrigo.vivi@gmail.com> References: <1349805046-4587-1-git-send-email-rodrigo.vivi@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org When cmd isn't IOC_IN | IOC_OUT a null "kdata" goes to "memset", which dereferences it. v2: simpler version just using usize = 0 instead of allocating useless memory Signed-off-by: Rodrigo Vivi Reviewed-by: Chris Wilson --- drivers/gpu/drm/drm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 1490e76..f72dce5 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -444,7 +444,8 @@ long drm_ioctl(struct file *filp, } if (asize > usize) memset(kdata + usize, 0, asize - usize); - } + } else + usize = 0; if (cmd & IOC_IN) { if (copy_from_user(kdata, (void __user *)arg,