From patchwork Wed May 18 20:17:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 9124671 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CE6639F1D3 for ; Thu, 19 May 2016 08:00:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB7CA20225 for ; Thu, 19 May 2016 08:00:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BFE3F20218 for ; Thu, 19 May 2016 08:00:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00E2C6E934; Thu, 19 May 2016 08:00:22 +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.15.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id D30536E013 for ; Wed, 18 May 2016 20:17:33 +0000 (UTC) Received: from LT001.lan ([62.143.92.134]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0M8edX-1bq9xB0a15-00wELc; Wed, 18 May 2016 22:17:30 +0200 From: Heinrich Schuchardt To: David Airlie Subject: [PATCH] drm/mm: avoid possible null pointer dereference Date: Wed, 18 May 2016 22:17:19 +0200 Message-Id: <1463602639-4861-1-git-send-email-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.1.4 X-Provags-ID: V03:K0:FiS+mghjzT0sSNN29xmEV7djbNNNdF0fwDiP8dMtr6PFz2qigO4 GhoLn6wU4plYtJ1gaZmOEjO4BXJYJD1vKbq//uS2dwa1wpvrJJdeXuAism6o8kYng4ozJpX aOCLzWyJGChv20gHADo8qAbJZ8LMkOHVGQN21TGm/8O99TqjDmctvV21f9YuKsQtjpX7DU9 MKMM7cXgkFdqVcnMQdUrw== X-UI-Out-Filterresults: notjunk:1; V01:K0:xhQj2fP60hc=:F59kRE4E7hV82lJGhDxbK+ j89VzTgxbWTroe3KNQz26tN+K0XTK6QFy6c7g5pXKBuvJZTe899FHA8SF0bGNtjXm1GR+IuZU Uegnv6Fz96eP1h/jKvRCAxiXwNnRanYsI/8MCn2RriaSLYh1X+iyaY/wzqMhxdUva553nwvde 4BzcCHO9tHr3tU+nTyPTH/3UCh47cdpulLpncb1PgzGMr/zcjt6uOs+s15eak6H1poAg7R5r8 Pp+6T86uXnrRw+1JV5sE1Nn/25lu7E+RioEFPRB41MNgsQH8OMZM0U8XS9UI5ehKwNuVp+A32 IylyLTWaNLACVvfgj8IWKU1QNSUpfu2Xy6UllDEHj65LjQey+l/vge3t24sFsd6j1+qtv9N+Q zu6fsKk8v8ks/00SMfVqR+/dMaGPm9OjJ/BWLDJdPUBCGTCTrBXcI7YyRXlYQiESBgbgr5Iwc ds8LSG1Xog7GlCaowhCm/Uw0z61GjhzOxsiirCHOWzQVpoVAzvmV7BILdqveaPk/nHpAaBZiZ WnbWRpDpA1VClgiLXXhBG2foIy6iR8IuoGBX+e+sXsC1DXRRrPATvWjmbswMvIgan7SS4rpbe ppMuz0iWPpsGktCUyvt+Xb8VoTISjX+5J3oO3+jVAgTpJAy5f4k4ZkRpEgxbobwTFNgj/ZfGh peBycijM7kwfb+QR2m7UB+kdk/FV6kMjONM/CR0HHhHHSeGdrvzfcOf6YRdk9iM1QK8qrnQ9Q vrdLGN4NUO7SgaBadz8bKG5D7KX5XC7T1amtE+OgStbQEEzeco/KXb2yUN0= X-Mailman-Approved-At: Thu, 19 May 2016 08:00:20 +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-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not dereference node before the check if node is NULL. Signed-off-by: Heinrich Schuchardt Reviewed-by: Eric Engestrom --- drivers/gpu/drm/drm_mm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 04de6fd..cb39f45 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -179,12 +179,14 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) { struct drm_mm_node *hole; - u64 end = node->start + node->size; + u64 end; u64 hole_start; u64 hole_end; BUG_ON(node == NULL); + end = node->start + node->size; + /* Find the relevant hole to add our node to */ drm_mm_for_each_hole(hole, mm, hole_start, hole_end) { if (hole_start > node->start || hole_end < end)