From patchwork Tue Dec 27 18:39:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 36979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1529232wrt; Tue, 27 Dec 2022 10:43:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXvc2wzH4F1U2/bMr2JQjd4Q0mPgv+64g9n9ZNonMJjGR+Ce1HWD60aWR8Y8q00LlyQVFwDS X-Received: by 2002:a05:6a20:1586:b0:ad:5a5d:3571 with SMTP id h6-20020a056a20158600b000ad5a5d3571mr35122263pzj.4.1672166637120; Tue, 27 Dec 2022 10:43:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672166637; cv=none; d=google.com; s=arc-20160816; b=rxtgaaNwglHl+c7pAQQfjSTOHRHszfYBNIPrVSol4eHg/hVwk19ekygZRJ4QxLO0ml 7qtrgazKvm5etkcRNGjOzhMNr6BjyXC1+nEdznTo2GCeS3YZay6u2cxISTqUD7LEsu9o GtftEUHpess6TLmU5wUJjA1R/2X9G3mWT3kDip6d+3L37RaRhbmVDAHeHLOfDCCdwNJE lGbx4BG5m4szypGlRaqBdzqxCpASNDc0Y1gjjkQPatajDJ7mIbJdZFKU/Yw0xBzEpaqw YSBLg8E7k1l/+7VcQFmw3oUSwc4jtvJ6hFnkT4b5BBs1oMF7lwUMyBpiZ/Yb+zHBv0Yg 38WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=g4WAIsqNSrDyOAodDmpq33iuLWoL5Ne46mvRqb/xibg=; b=DXSu2QaIOo7vEg/wP2IjcgLk2LzrIguclEsvg/P3q0L2GiWwSH3QBlCq0qoZv3VpoH zhJEmmd2cIRDHhnaFs/s3hhWYoqgtUcgkY6hmvyF+l4XTNcFd9fuN96XT18MBmrUKUw+ F7zDXfQtO8zOdovVmNP5182DIBQwAbj0mx5o2z5uqw3dVOe91J38YNA+p/qOzfPg1jUW AAipdlUde8kqtqtqrzCwvGHg2QNrHGaNDybsEhw+yZFAguZ+8GnE3wHGTXp5iwWj0+vH ul9ltDZBzE+4SJUwTr28KiozPvMLFkWINBEwAC0jZL0RiFCGJ0RT7c8Eq0jsyCgIvPNv mtSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=WKhCbjYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g38-20020a631126000000b00478ba6bbac1si14063950pgl.699.2022.12.27.10.43.44; Tue, 27 Dec 2022 10:43:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=WKhCbjYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbiL0SkR (ORCPT + 99 others); Tue, 27 Dec 2022 13:40:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbiL0SkN (ORCPT ); Tue, 27 Dec 2022 13:40:13 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08271D13B for ; Tue, 27 Dec 2022 10:40:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672166397; bh=RwCjMF4IElXUvBXwhEZqyWB6/DKy3YsKX+XdaMVUsvM=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=WKhCbjYRrGHbYaCyfgvtIeC2qSJLkYQMbGwa+AM5w7bOVHkJQ3H58YhWrEqta4t9Q VW51Sb0djGuJcCafSzqKSCbJ1ZC9W8yZvEo6Ch6xvt7HeJSlESl1dy1dUAUpqc0gaL +hyUvApOiOVYurgKLif3aGbv8JCrIKB2A3uTQQFw= Received: by b-4.in.mailobj.net [192.168.90.14] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 27 Dec 2022 19:39:57 +0100 (CET) X-EA-Auth: 9pilygPs5f1CcxVxTT74knypQP9F1WtW7YJ8Z3yo0hcU4sAac4BT157vjGdHaAt+fnEHQI+rYwZqjWcWe1ZLRBNrPrqhMvCS Date: Wed, 28 Dec 2022 00:09:51 +0530 From: Deepak R Varma To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , Christian =?iso-8859-1?q?K=F6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] drm/amd/display: No need for Null pointer check before kfree Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753393803698254088?= X-GMAIL-MSGID: =?utf-8?q?1753393803698254088?= kfree() & vfree() internally performs NULL check on the pointer handed to it and take no action if it indeed is NULL. Hence there is no need for a pre-check of the memory pointer before handing it to kfree()/vfree(). Issue reported by ifnullfree.cocci Coccinelle semantic patch script. Signed-off-by: Deepak R Varma Reviewed-by: Rodrigo Siqueira --- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c | 3 +-- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c index 3ce0ee0d012f..694a9d3d92ae 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c @@ -577,8 +577,7 @@ void dcn3_clk_mgr_construct( void dcn3_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr) { - if (clk_mgr->base.bw_params) - kfree(clk_mgr->base.bw_params); + kfree(clk_mgr->base.bw_params); if (clk_mgr->wm_range_table) dm_helpers_free_gpu_mem(clk_mgr->base.ctx, DC_MEM_ALLOC_TYPE_GART, diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c index 200fcec19186..ba9814f88f48 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c @@ -783,8 +783,7 @@ void dcn32_clk_mgr_construct( void dcn32_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr) { - if (clk_mgr->base.bw_params) - kfree(clk_mgr->base.bw_params); + kfree(clk_mgr->base.bw_params); if (clk_mgr->wm_range_table) dm_helpers_free_gpu_mem(clk_mgr->base.ctx, DC_MEM_ALLOC_TYPE_GART,