diff mbox series

drm/amdgpu/acpi: NULL check before some freeing functions is not needed

Message ID 20181205074319.25030-1-wen.yang99@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series drm/amdgpu/acpi: NULL check before some freeing functions is not needed | expand

Commit Message

Wen Yang Dec. 5, 2018, 7:43 a.m. UTC
kfree(NULL) is safe, so removes NULL check before freeing the mem.
This patch also fix the ifnullfree.cocci warnings.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Alex Deucher <alexander.deucher@amd.com>
CC: christian.koenig@amd.com
CC: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
CC: David Airlie <airlied@linux.ie> (maintainer:DRM DRIVERS)
CC: Lyude Paul <lyude@redhat.com>
CC: Rex Zhu <Rex.Zhu@amd.com>
CC: Jim Qu <Jim.Qu@amd.com>
CC: amd-gfx@lists.freedesktop.org
CC: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Lyude Paul Dec. 5, 2018, 7:02 p.m. UTC | #1
Reviewed-by: Lyude Paul <lyude@redhat.com>

Thanks!

On Wed, 2018-12-05 at 15:43 +0800, Wen Yang wrote:
> kfree(NULL) is safe, so removes NULL check before freeing the mem.
> This patch also fix the ifnullfree.cocci warnings.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> CC: Alex Deucher <alexander.deucher@amd.com>
> CC: christian.koenig@amd.com
> CC: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> CC: David Airlie <airlied@linux.ie> (maintainer:DRM DRIVERS)
> CC: Lyude Paul <lyude@redhat.com>
> CC: Rex Zhu <Rex.Zhu@amd.com>
> CC: Jim Qu <Jim.Qu@amd.com>
> CC: amd-gfx@lists.freedesktop.org
> CC: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 7f0afc526419..996bfce149f2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -816,6 +816,5 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
>  void amdgpu_acpi_fini(struct amdgpu_device *adev)
>  {
>  	unregister_acpi_notifier(&adev->acpi_nb);
> -	if (adev->atif)
> -		kfree(adev->atif);
> +	kfree(adev->atif);
>  }
Alex Deucher Dec. 5, 2018, 10:20 p.m. UTC | #2
Applied.  thanks!

Alex
On Wed, Dec 5, 2018 at 2:02 PM Lyude Paul <lyude@redhat.com> wrote:
>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
>
> Thanks!
>
> On Wed, 2018-12-05 at 15:43 +0800, Wen Yang wrote:
> > kfree(NULL) is safe, so removes NULL check before freeing the mem.
> > This patch also fix the ifnullfree.cocci warnings.
> >
> > Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> > CC: Alex Deucher <alexander.deucher@amd.com>
> > CC: christian.koenig@amd.com
> > CC: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> > CC: David Airlie <airlied@linux.ie> (maintainer:DRM DRIVERS)
> > CC: Lyude Paul <lyude@redhat.com>
> > CC: Rex Zhu <Rex.Zhu@amd.com>
> > CC: Jim Qu <Jim.Qu@amd.com>
> > CC: amd-gfx@lists.freedesktop.org
> > CC: dri-devel@lists.freedesktop.org
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > index 7f0afc526419..996bfce149f2 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > @@ -816,6 +816,5 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
> >  void amdgpu_acpi_fini(struct amdgpu_device *adev)
> >  {
> >       unregister_acpi_notifier(&adev->acpi_nb);
> > -     if (adev->atif)
> > -             kfree(adev->atif);
> > +     kfree(adev->atif);
> >  }
> --
> Cheers,
>         Lyude Paul
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 7f0afc526419..996bfce149f2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -816,6 +816,5 @@  int amdgpu_acpi_init(struct amdgpu_device *adev)
 void amdgpu_acpi_fini(struct amdgpu_device *adev)
 {
 	unregister_acpi_notifier(&adev->acpi_nb);
-	if (adev->atif)
-		kfree(adev->atif);
+	kfree(adev->atif);
 }