From patchwork Fri Jul 15 20:44:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9232699 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 ADE256075D for ; Fri, 15 Jul 2016 20:44:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 963F222A68 for ; Fri, 15 Jul 2016 20:44:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AB6226E69; Fri, 15 Jul 2016 20:44:57 +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, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78CC022A68 for ; Fri, 15 Jul 2016 20:44:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F4986EAE7; Fri, 15 Jul 2016 20:44:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [212.227.17.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7ED96EAE7 for ; Fri, 15 Jul 2016 20:44:47 +0000 (UTC) Received: from [192.168.1.2] ([77.182.179.66]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MYw63-1btDEs2q2t-00ViA8; Fri, 15 Jul 2016 22:44:38 +0200 Subject: [PATCH] drm/virtgpu: Delete unnecessary checks before drm_gem_object_unreference_unlocked() To: David Airlie , Gerd Hoffmann , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> From: SF Markus Elfring Message-ID: <5e3dafff-72bb-e616-e84a-368f78fa66b1@users.sourceforge.net> Date: Fri, 15 Jul 2016 22:44:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:nWAXlmi3m8QlPc5PkhT1zA8iQTjIW6XtrJQ2rKZtao1xEEd+6aw 3usD9zSP3Kkz4p7pLJKyvEEwE3/IthcLYqGT/DMJ61ts7TggEiWhFg/HUyMJPlLlKlobsGe e+ImetrqhVRvG2hR/QhT+TtxMVOeB1DwLW/o7D6CKwY9tncgM6SdSUZ6gIDl1+0IGwqQAaP EZAReUkTgk16pxTT1LeeQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:6Gn9TdCqhx8=:xXxI3hvIJP4cxBCqBfqnqu YSr8rxQfJbtPieNVl6wQUm5ZajvwrGjkLBiT34fjXu2DLvrefquEOqn8uvpTRskTn9TMUqNIQ SsJT+Sx+aN8J53Nr8ohqz5I7Uj8MBRQQV94BsOs11L2zghj2A9X/pRD6UIP10pwVqRawllEGK LvnVbdbXZDmP6TNpJEhtom5rjyLJdjA8V4fXqv/+QcKAPA3S6kqU8rq0pREIiG5hAjK+Tnpev g6goLwbXPCQMl449LWAyiMwep+pqrFCQYotyWJpc++kp6vmS221xSEzgH9+L/S+l+rIqV7d5e kcrASYgV9PYQh7mmk6Pm9Gk5iJsiY5BrwZTS2H+k6gLf9lnzosd/5UwktP0Mw2u4h0nTGc+0P ak3zv2/ZYXLVfSmKDpAR5XKWZtMBPFdHtdFWzNMkbkB5G1sEOV9As/bAEStsyx1Xt6izAOdFo CxLz7+gpZsiqRrmPt2KGDfwC6VhfIeahTUuFVnr3bux6Ij/KDBbiPreg9r2CExy6btsjeSwdV 0a6puiReuIFpxNN7YTrNHgoRAT/zEStEvjuUMGZ1TNQ10Yy0gPlBJSNjWAdvjHjvtYBEf74Es fP5Zz5mLfUlOUFLcAmShONXJVbAwWRpoOUbU5z6GLj5Q0hhWwFD44yic/iljJRuyNAggUmRid YWHHRzppxFvvOpz3UX3FgWkyHp0I9XYMn9tTBlPSz43qSaIu4/1Q0cI7YWAoeHjqRzKRx0kHj kM72tTq6nnRXzWTtMl0l4aS8cH8XSkbOg0JvyejYlei+Lmj4kltj30++DiszA3FhTwG1GkQZR /It4jLl Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 15 Jul 2016 22:38:42 +0200 The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/gpu/drm/virtio/virtgpu_display.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c index ac758cd..fdfc711 100644 --- a/drivers/gpu/drm/virtio/virtgpu_display.c +++ b/drivers/gpu/drm/virtio/virtgpu_display.c @@ -53,8 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct drm_framebuffer *fb) struct virtio_gpu_framebuffer *virtio_gpu_fb = to_virtio_gpu_framebuffer(fb); - if (virtio_gpu_fb->obj) - drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj); + drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj); drm_framebuffer_cleanup(fb); kfree(virtio_gpu_fb); } @@ -326,8 +325,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj); if (ret) { kfree(virtio_gpu_fb); - if (obj) - drm_gem_object_unreference_unlocked(obj); + drm_gem_object_unreference_unlocked(obj); return NULL; }