All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Mikko Perttunen <cyndis@kapsi.fi>
Cc: Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	Saurabh Singh Sengar <ssengar@microsoft.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Deepak R Varma <drv@mailo.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH] drm/tegra: submit: No need for Null pointer check before kfree
Date: Wed, 28 Dec 2022 18:38:48 +0530	[thread overview]
Message-ID: <Y6w/4IzoMFsVnCmu@qemulion> (raw)
In-Reply-To: <864f2fdd-4289-a178-bbf1-c2a6a579c58c@kapsi.fi>

On Wed, Dec 28, 2022 at 02:28:54PM +0200, Mikko Perttunen wrote:
> 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 <drv@mailo.com>
> > ---
> >   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.

Hello Mikko,
Thank you for responding to the patch proposal. Could you please explain why is
this bad?

Regards,
./drv

>
> Mikko



WARNING: multiple messages have this Message-ID (diff)
From: Deepak R Varma <drv@mailo.com>
To: Mikko Perttunen <cyndis@kapsi.fi>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Saurabh Singh Sengar <ssengar@microsoft.com>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	Deepak R Varma <drv@mailo.com>
Subject: Re: [PATCH] drm/tegra: submit: No need for Null pointer check before kfree
Date: Wed, 28 Dec 2022 18:38:48 +0530	[thread overview]
Message-ID: <Y6w/4IzoMFsVnCmu@qemulion> (raw)
In-Reply-To: <864f2fdd-4289-a178-bbf1-c2a6a579c58c@kapsi.fi>

On Wed, Dec 28, 2022 at 02:28:54PM +0200, Mikko Perttunen wrote:
> 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 <drv@mailo.com>
> > ---
> >   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.

Hello Mikko,
Thank you for responding to the patch proposal. Could you please explain why is
this bad?

Regards,
./drv

>
> Mikko



  reply	other threads:[~2022-12-28 13:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 17:14 [PATCH] drm/tegra: submit: No need for Null pointer check before kfree Deepak R Varma
2022-12-27 17:14 ` Deepak R Varma
2022-12-28 12:28 ` Mikko Perttunen
2022-12-28 12:28   ` Mikko Perttunen
2022-12-28 13:08   ` Deepak R Varma [this message]
2022-12-28 13:08     ` Deepak R Varma
2022-12-28 13:17     ` Mikko Perttunen
2022-12-28 13:17       ` Mikko Perttunen
2022-12-28 13:34       ` Deepak R Varma
2022-12-28 13:34         ` Deepak R Varma
2022-12-28 13:48         ` Mikko Perttunen
2022-12-28 13:48           ` Mikko Perttunen
2022-12-28 14:18           ` Deepak R Varma
2022-12-28 14:18             ` Deepak R Varma
2022-12-30  9:15       ` Stanislaw Gruszka
2022-12-30  9:15         ` Stanislaw Gruszka
2022-12-30 10:01         ` Mikko Perttunen
2022-12-30 10:01           ` Mikko Perttunen
2022-12-30 10:03           ` Mikko Perttunen
2022-12-30 10:03             ` Mikko Perttunen
2023-01-02 18:20             ` Deepak R Varma
2023-01-02 18:20               ` Deepak R Varma
2023-01-22 18:18               ` Deepak R Varma
2023-01-22 18:18                 ` Deepak R Varma
2022-12-30 10:15           ` Stanislaw Gruszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6w/4IzoMFsVnCmu@qemulion \
    --to=drv@mailo.com \
    --cc=cyndis@kapsi.fi \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathanh@nvidia.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=ssengar@microsoft.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.