From patchwork Sun Aug 21 21:06:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 9292781 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 52015600CB for ; Mon, 22 Aug 2016 00:40:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 457CE287DE for ; Mon, 22 Aug 2016 00:40:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A5A6287FF; Mon, 22 Aug 2016 00:40:22 +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 DD0EF287DE for ; Mon, 22 Aug 2016 00:40:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 708F56E2B8; Mon, 22 Aug 2016 00:40:15 +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 293E06E156 for ; Sun, 21 Aug 2016 21:06:21 +0000 (UTC) Received: from workstation4.fritz.box ([109.91.48.91]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MaZrd-1brKRg1c77-00KAaS; Sun, 21 Aug 2016 23:06:13 +0200 From: Heinrich Schuchardt To: Gerd Hoffmann , David Airlie Subject: [PATCH 1/1] virtio-gpu: avoid possible NULL pointer dereference Date: Sun, 21 Aug 2016 23:06:06 +0200 Message-Id: <1471813566-5324-1-git-send-email-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.1.4 X-Provags-ID: V03:K0:WRBbSshwmsgQFdTWieq1mtDqaCEMdcov+EQcLcmNojT94xVYM7b D0ZeYoA26zmp8zXWn/AcSgb6kT5WKJcOsERfWGsn9jSj/5SQaTe8VL+lQsDw12P602gf6i5 fWclgIX4HJdzeQI/UAPtHPN8YvTGd1vxnKvD5ui/l3KY5AhuhU5WHomK1d9+ndDMK6XHW3i Mvc1F/A3sUr1QaO4WUwuQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:yyHXv+B8b+0=:92QLCBk4n/uY3Unbx9IlRX TLlLmi6M6YN9N+ly66LHrXzQ0wyfAxGO2HxrAKM9HJMeBUtcssQholZlklUT51p0Ixi4YZWkA EQhhSemN9699wprKJ9Jq3PWXNlOuFDV2SEubx2xDgobg5Y6Pfxv6Ng84hFGE4Ylm6lW1cnmuH PP0L37Vwz1xdsbMabPRWl4TKw+VwYWOUJY8PZQed6JCurYElZ79gRFrzTGgtckva3J8LItArg FJtaWs+NzV8UZ2KXB4x91GFTHXR7g3NC3rHiGodrKDb59XUpX+07sjqUiha53oWbw7sItI+qE /gxCOHqSW3u49/N4ZhQJ0W1Vc5uVFV5Qnxh4aLS3pfiM3iAgJUk8VXPNvBjZ1pLpVCP45YKv4 XvCJV2jzQ+SyY51USI5IBORDPRJq4XFRigeBdA/zLfIFk8dqBpXkjsXTfGeZAkRlS39gR0XHk JeCSprvQpaZfz4OGwk1AQiQbkPjjnEPtdmd3fD2G0svaLx1yx7aipFWWnQM3THFm+0Vz4v8mz nMziaTKKU7p6OxPV3owEx1F4+eo4RTgZI6xHYxZOwzbZ1n/vi4ibBwl51tXMlHljOxAzbEA45 rNUaSQH9eAhVnVgqmhcyFlNTuvyxPuQF6z8FILwrAqt3XSkMbD9CFGoT5E/QNJAQ/J2pGt7XL 5+KUmD2Vb629rsQ9Q1CUB355WizF+VnmH3+cjQuAwpNpHGb7l0xG+6JieuUDwxOFy07lUjFig AqScKmUOIHWN3HeU0qItuRQL2FwJdimkHWtJ+f+y1sgnkYxts3lQ7XT3PkA= 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, virtualization@lists.linux-foundation.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 If output is NULL it is not permissable to dereference it. So we should leave the respective function in this case. The inconsistency was indicated by cppcheck. No actual NULL pointer dereference was observed. Signed-off-by: Heinrich Schuchardt --- drivers/gpu/drm/virtio/virtgpu_plane.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index 925ca25..ba28c0f 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -76,7 +76,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); if (old_state->crtc) output = drm_crtc_to_virtio_gpu_output(old_state->crtc); - WARN_ON(!output); + if (WARN_ON(!output)) + return; if (plane->state->fb) { vgfb = to_virtio_gpu_framebuffer(plane->state->fb); @@ -129,7 +130,8 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane, output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); if (old_state->crtc) output = drm_crtc_to_virtio_gpu_output(old_state->crtc); - WARN_ON(!output); + if (WARN_ON(!output)) + return; if (plane->state->fb) { vgfb = to_virtio_gpu_framebuffer(plane->state->fb);