From patchwork Wed Jul 13 18:01:27 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: 9228357 X-Patchwork-Delegate: agross@codeaurora.org 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 9E8C960572 for ; Wed, 13 Jul 2016 18:03:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 949A927165 for ; Wed, 13 Jul 2016 18:03:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8995527F4B; Wed, 13 Jul 2016 18:03:48 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5211928068 for ; Wed, 13 Jul 2016 18:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751209AbcGMSCf (ORCPT ); Wed, 13 Jul 2016 14:02:35 -0400 Received: from mout.web.de ([212.227.15.14]:60435 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbcGMSCe (ORCPT ); Wed, 13 Jul 2016 14:02:34 -0400 Received: from [192.168.1.2] ([78.53.182.169]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0Lmchn-1anmfr3CtP-00aCBG; Wed, 13 Jul 2016 20:01:28 +0200 Subject: [PATCH 2/3] drm/msm: Delete unnecessary checks before drm_gem_object_unreference_unlocked() To: David Airlie , Rob Clark , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.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> <351a1279-b0ca-5f5e-d175-28c9de8406f6@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <9120ad90-45d1-1c01-fc84-65c431b5ca4f@users.sourceforge.net> Date: Wed, 13 Jul 2016 20:01:27 +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: <351a1279-b0ca-5f5e-d175-28c9de8406f6@users.sourceforge.net> X-Provags-ID: V03:K0:InFHhA2/JCJQXTj0GpCegNiPgInyC/by44zqxsfqYYPawudLIAc o5FHd5Mj27UW+O4hT08spaXiCwnpLUe16BnuWGRvGGwryX2k2ecXwIH+wK8RSoIxOEcTSnE lkxyFysmRyI2e1Yy1skQJdQ24EavBBXUKbfEjf30F7jLz9q/nradxrzUOfZPmj982NJfsdk s6kFnVJbtei2eYERg2UdA== X-UI-Out-Filterresults: notjunk:1; V01:K0:tUhJXIvQkAE=:rQUtGfCt2DaMLgu77DkH5C Q4V6Hn/03NdndEvGCMKY7lbZmqVXmbzH0JI2t5RZ77N1fpMY/905xpbWSOo0N5HfOy5bfNLpg MA1ePhtdCZEDOOgAbgvMNq/qie2X6zH/u3oxrhghhqYys2gJuAoSCOcbIOTPWzKSv+X4hcSFC 5Q5WdPTwe073twf6bYmoJfijd2Hr+iTOK1goUpijGrbD2OIrcUtmnqgz6/fbgy7NZM50tyXSM qEroseiQt9hsXke/dKgWHHER7XEdRQuyRkaRL0yEi9nI+8zWzjSM8csaUSmMx9fIKijFcVGqb wrg1vyvG69+1RQq/npSntjX9miwq4WFWJ3eHkvzl2n2/VM/YnN4WVyl1KfgTgfkdjQqsI9szx QLqpDeiGum+I+pPacaohCkHQAH9ctEgrJRPNciPP9jHHu5G87STd2VD4wYGJNZWCUl24PwSfL yf4zH8KaE6ruQX8bYgUAvvhcVXC5HKmIc9Mjx9wGTO9rXiTVe/tmUlYTpty8rE692qstZtyGQ h4KSbtk0zCWkEPdwx30+qLZeBWKM0uKoyDVtYVJN1RVkEDV3EjHPiJDlXquv/EQtqBW8DPlsg m7htLMquqtCugMlE6PS/SOyrXYDfmhPoq4C0FaBxdyHzyM0l2VKJf5pmXDQQ5ugpX+aejD19t fgro1OGzgp61o1h+DZ08KCgQ6huHDDajP/EZXA0hhNVaZjbuWBuIkXTQ0+3eFLwN324yXI7PB cQoFHOF5kJemxOfGziyXNxvY4MOiUX1GVhOqKizsIpIgUHq2XTcCCAzsvJSPgdQieRQfhy9NF adhXC9X Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 13 Jul 2016 19:15:35 +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/msm/mdp/mdp4/mdp4_kms.c | 3 +-- drivers/gpu/drm/msm/msm_fb.c | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c index ba8df15..7b39e89 100644 --- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c @@ -168,8 +168,7 @@ static void mdp4_destroy(struct msm_kms *kms) if (mdp4_kms->blank_cursor_iova) msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id); - if (mdp4_kms->blank_cursor_bo) - drm_gem_object_unreference_unlocked(mdp4_kms->blank_cursor_bo); + drm_gem_object_unreference_unlocked(mdp4_kms->blank_cursor_bo); if (mdp4_kms->rpm_enabled) pm_runtime_disable(dev); diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c index 7919c24..95cf8fe 100644 --- a/drivers/gpu/drm/msm/msm_fb.c +++ b/drivers/gpu/drm/msm/msm_fb.c @@ -49,8 +49,8 @@ static void msm_framebuffer_destroy(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct drm_gem_object *bo = msm_fb->planes[i]; - if (bo) - drm_gem_object_unreference_unlocked(bo); + + drm_gem_object_unreference_unlocked(bo); } kfree(msm_fb); diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 886cfe0..9a713fb 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -875,8 +875,6 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, return obj; fail: - if (obj) - drm_gem_object_unreference_unlocked(obj); - + drm_gem_object_unreference_unlocked(obj); return ERR_PTR(ret); }