All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Monk.Liu@amd.com
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/amdgpu: fix memleak in pptable_init
Date: Wed, 30 Nov 2016 22:18:41 +0300	[thread overview]
Message-ID: <20161130191841.GA28180@mwanda> (raw)

Hello Monk Liu,

The patch 9d8f086cd059: "drm/amdgpu: fix memleak in pptable_init"
from May 30, 2016, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/../powerplay/amd_powerplay.c:107 pp_sw_fini()
	error: dereferencing freed memory 'hwmgr'

drivers/gpu/drm/amd/amdgpu/../powerplay/amd_powerplay.c
    90  static int pp_sw_fini(void *handle)
    91  {
    92          struct pp_instance *pp_handle;
    93          struct pp_hwmgr  *hwmgr;
    94          int ret = 0;
    95  
    96          if (handle == NULL)
    97                  return -EINVAL;
    98  
    99          pp_handle = (struct pp_instance *)handle;
   100          hwmgr = pp_handle->hwmgr;
   101  
   102          PP_CHECK_HW(hwmgr);
   103  
   104          if (hwmgr->hwmgr_func->backend_fini != NULL)
   105                  ret = hwmgr->hwmgr_func->backend_fini(hwmgr);

The cz_hwmgr_backend_fini() function frees "hwmgr".

   106  
   107          if (hwmgr->pptable_func->pptable_fini)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But we dereference it on the next line which won't work.

   108                  hwmgr->pptable_func->pptable_fini(hwmgr);
   109  
   110          return ret;
   111  }

regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2016-11-30 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 19:18 Dan Carpenter [this message]
2017-01-26  6:44 ` [bug report] drm/amdgpu: fix memleak in pptable_init Dan Carpenter

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=20161130191841.GA28180@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=Monk.Liu@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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.