From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42D2AC3DA7A for ; Wed, 28 Dec 2022 12:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232605AbiL1M3g (ORCPT ); Wed, 28 Dec 2022 07:29:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiL1M31 (ORCPT ); Wed, 28 Dec 2022 07:29:27 -0500 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AF2BE4; Wed, 28 Dec 2022 04:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=S5A82/vTyB3E2qT0vPwrQFPcNR5JLZTUdXm1+CZZGm4=; b=tNoMND1zfSVEkRkapAe2SLkvk7 fd5mxSYnQi6ax/CA3Mjd3eZLODVxSQokSsyTWPohYXRhea7L8rNqQNo+yq3070vKuqreS5YXZgnga 701DTc5Xu0hmurfmugUFF71WnfJfctEkSuhffIku+n9q61MBigcnJxbkrNGfdm6Mjbh1TmzZVPthK V7BOhzMIgGVlAGtT4CmQm6FF2OE1PzPUgzcsVj3xulqcjQbhScMGC//YXY1W30icwCEd1JlB+3eDQ Z7gKCr7G5GdEaFWzIdBiEcb8/VsBlY0vGezsi3gYRkRy8Qb36JPkmy08qsiYqVKWjui4U8gsNBSsO 3XyXF9jg==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=[192.168.1.10]) by mail.kapsi.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pAVYY-008VYL-HA; Wed, 28 Dec 2022 14:29:14 +0200 Message-ID: <864f2fdd-4289-a178-bbf1-c2a6a579c58c@kapsi.fi> Date: Wed, 28 Dec 2022 14:28:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] drm/tegra: submit: No need for Null pointer check before kfree To: Deepak R Varma , 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 References: Content-Language: en-US From: Mikko Perttunen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/27/22 19:14, Deepak R Varma wrote: > 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(-) > > 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: > -- > 2.34.1 > > > It continues to be the case that I think this transform is bad. Same applies to the host1x patch. Mikko