From patchwork Sun Aug 21 21:16:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 9292779 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 2441A600CB for ; Mon, 22 Aug 2016 00:40:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16A00287DE for ; Mon, 22 Aug 2016 00:40:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B379287FF; Mon, 22 Aug 2016 00:40:21 +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,FREEMAIL_FROM, 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 C1D05287DE for ; Mon, 22 Aug 2016 00:40:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C6F5E6E2BC; Mon, 22 Aug 2016 00:40:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id D95046E25F for ; Sun, 21 Aug 2016 21:16:31 +0000 (UTC) Received: from workstation4.fritz.box ([109.91.48.91]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LiWzQ-1b1PwJ2o3Q-00cf9B; Sun, 21 Aug 2016 23:16:23 +0200 From: Heinrich Schuchardt To: VMware Graphics , Sinclair Yeh , Thomas Hellstrom , David Airlie Subject: [PATCH 1/1] drm/vmwgfx: avoid possible NULL pointer dereference Date: Sun, 21 Aug 2016 23:16:17 +0200 Message-Id: <1471814177-5472-1-git-send-email-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.1.4 X-Provags-ID: V03:K0:j7v9FjqS8VPOv1BO53j3taVCzYh3Oq/vsPB+S3LQmCVEi6yZkTX +Oo11BfyMJNnUitQNgDsWnBqVHTvL2VuEz+hfr+Xql4BmKaliXJYiMyRqF/lZgNXqRDC+93 v/Az2kQFS6dimWXRaPPJ8N5GHWqps1Lv8HgoNykx44x7HU1V+h1Ssm4Q/oMradO7tDx5s06 Bqd2vf+zCiS6n0gqptnKA== X-UI-Out-Filterresults: notjunk:1; V01:K0:HpbO5dGvCCg=:AJ1uVNWABvZTSEFCGLbMxu hG9aG5sz+yy4x9VMGk/XbtdL5j1Gpp8rNUGGmOx2arRrNV/DFYgsmpMIophjLj+Tqv3S9LjeX fMXlKPGBnJOlEi0megGM/WhnjrSOl2hg3vcM3U9OZ93yCLeBjHCL9skQ5HRX60W/AOcw26+AZ ykAGiD8Y2mUp0pOnqmic84yF9RrF8UU+7dRdmM+JFcH2h9kneThgUVoLSJ9zpPaszarI2a/Bx XEGvZO1MOV6lFt6dkiLjWB3sAxUSqP/oac+hf9pPdsSNxnU3VJe7k7E5E8z/mDDHL0RsfHaO3 SKuVfyp+328ML/xa71Fiag7h1NcDeNY9VO8MuNqmcARjb4KAf/rtIC3a0b/ck6dfIckluSumd gQto3XmxV7E02X++d/ag/IWRf7QKYDLCWJw3Yb0AfL3fhqx+jyzdyegiEuklW9w2+FrnUrPE6 Uvk+wslZdzTcJZfwnnFPm3s4RpvSZeHkZ83rmWS071e91CgyaHJwPS8H7PNkGNqyCGAUC2hrK f2PVerokpw989PQ/Z5C/3sy/idbUWaWxAlcm5WCEL3J5yNaejb1HPLfQVQSvU6SXId+st2rku joSCdGFeB8xjInPJ/UuYHXTjrK4L640RKBEy/HLoGe2RAsuLNLf8C7q+G3nGtYAb+JCEkCsmR FXqExdqXnfFM96mgOWKskoU7U0FwTYlG+8FPJTcSyzE6PEHigVmfnXiLwjCDFykYXYRYs8XUB AYM6Jtu6iOyk5DplJvuvOhG8VRLh4a1c1QF17YArTytx3GS/03b5PeP10Ms= X-Mailman-Approved-At: Mon, 22 Aug 2016 00:39:59 +0000 Cc: Heinrich Schuchardt , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The comment describing function vmw_cmd_res_reloc_add explicitely mentions p_val may be NULL. We should not assign a value (NULL) to *p_val in this case. Signed-off-by: Heinrich Schuchardt --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index dc5beff..0363989 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -652,7 +652,11 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv, int ret; struct vmw_resource_val_node *node; + if (!p_val) + return; + *p_val = NULL; + ret = vmw_resource_relocation_add(&sw_context->res_relocations, res, id_loc - sw_context->buf_start); @@ -663,8 +667,7 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv, if (unlikely(ret != 0)) return ret; - if (p_val) - *p_val = node; + *p_val = node; return 0; }