From patchwork Tue Dec 27 17:14:21 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: 36973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1504046wrt; Tue, 27 Dec 2022 09:43:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwLXNl/PMLk6a4et2ZmQ7nS5RudFLiHK9NfERUJXzgoUca4PXrc1hWrv4KDeN1IUieBeef X-Received: by 2002:a17:902:eb84:b0:192:8e8b:59ab with SMTP id q4-20020a170902eb8400b001928e8b59abmr2454030plg.9.1672163032147; Tue, 27 Dec 2022 09:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672163032; cv=none; d=google.com; s=arc-20160816; b=zwO5wIOb49HypRR2KHLeFGRaroqznC6zGOM58XU6bxqWvY/iviE1OVePzsmwQkQsAM 1Qxo9TTXHPNmQH//k8eoGYkTf3r81bQ1TtRmXRLSvDxoYMs07MQ1Pbk+0W8McYExXyRR 9TYOepEn8muHVOVoakda0oD9vK/n8H4XlSpO04xaY4C/p0W8RFgeJA6tkDMF3hukD5zi WeLGSYyl3HuttccatwJ3nl4RzHad8YLom8i91pi5LTnk31lHeqySalUjCjJ7k7jR/4OI x18Bm9ww5tDUlBYsn8TuWMM/DpGXxD07WDQGni7xuWe/KWhVFKktcH5qy/3tmuKhagXy 3lSg== 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=mXDq2twm7AMJjSe3SF3E0znzKISr4JsiPRRtCic8muY=; b=CMpBNB7B3Q1AzzvZHr4oYeBi73zvxWn/jluKGlAHeFwjm9AkpWvketu/4rCat75nGd XFdrzBMrhrcZbRQ87RjnVgBqH+vDB/GCn138rjZos40TRuHsgRJYnf/ZvetNYjbjpcDb AZGF4mjVctr5oFkB+1P6rA8nkp+zA1EFY31gv8FneNn4O33wHP3r9eTLQOHxPkSHiFZw rL20hy4N+Hp2Kls/GpHWuTIJRgSmeUtV4V0NfSKuwYwKnleR/0vD8fIY7kQtZNDWY2+D I93WaF5C8pN4+/ny6mbi926sMkqRJl1UVlXzbtMWpVxskkLx8AWG+3ArWHqfD52Mc2Fk RttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=PFvbFEkO; 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 k3-20020a170902d58300b001927aa58c73si5574311plh.203.2022.12.27.09.43.40; Tue, 27 Dec 2022 09:43:52 -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=PFvbFEkO; 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 S229911AbiL0ROp (ORCPT + 99 others); Tue, 27 Dec 2022 12:14:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbiL0ROh (ORCPT ); Tue, 27 Dec 2022 12:14:37 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86A4BF7F; Tue, 27 Dec 2022 09:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672161267; bh=t7PT2uktgkerHfBW8tbhYinlf/iWYlEafzcWDES++jM=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=PFvbFEkOjToKt4pNFDu81BSQhHuNoyMGKRRB1qLS/ma35bUMEGFGb4WWuIzm+JJs9 /KBGjbdAWvKBrsl3hbI1VMkzh1m1q+B3NyPN3EnwTckyAp7FEHxf/2DsKzWa0yKogr xUhVjDhHGShJfc1i/8vvL0xMSqkEAQYpGRcPYHvE= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 27 Dec 2022 18:14:27 +0100 (CET) X-EA-Auth: kTiepSjWpyi9Ji8iWRK5eWeMrKdUoRK+JaiTVgN5jm3nna2m7biYtAmN9vNNkbmNg67H6j5YGy8WqhY1z1C7Uqq/5buDi/8h Date: Tue, 27 Dec 2022 22:44:21 +0530 From: Deepak R Varma To: Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] drm/tegra: submit: 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?1753390023578717609?= X-GMAIL-MSGID: =?utf-8?q?1753390023578717609?= kfree() & vfree() internally perform 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 --- drivers/gpu/drm/tegra/submit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c index 066f88564169..06f836db99d0 100644 --- a/drivers/gpu/drm/tegra/submit.c +++ b/drivers/gpu/drm/tegra/submit.c @@ -680,8 +680,8 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, kfree(job_data->used_mappings); } - if (job_data) - kfree(job_data); + kfree(job_data); + put_bo: gather_bo_put(&bo->base); unlock: