All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [chrome-os:chromeos-5.4 11/13] drivers/gpu/drm/virtio/virtgpu_kms.c:315 virtio_gpu_driver_open() warn: possible memory leak of 'vfpriv'
Date: Fri, 19 Mar 2021 11:18:00 +0300	[thread overview]
Message-ID: <20210319081800.GE21246@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3445 bytes --]

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel  chromeos-5.4
head:   aaac331bb0ff1bdb6ca7d9f12634a7028df6addc
commit: b182d75023cbf6ff0ab079ac0377399d6096d7c2 [11/13] CHROMIUM: drm/virtio: implement context init: support init ioctl
config: i386-randconfig-m021-20210318 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/virtio/virtgpu_kms.c:315 virtio_gpu_driver_open() warn: possible memory leak of 'vfpriv'

vim +/vfpriv +315 drivers/gpu/drm/virtio/virtgpu_kms.c

62fb7a5e10962a Gerd Hoffmann   2014-10-28  295  int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  296  {
62fb7a5e10962a Gerd Hoffmann   2014-10-28  297  	struct virtio_gpu_device *vgdev = dev->dev_private;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  298  	struct virtio_gpu_fpriv *vfpriv;
b182d75023cbf6 Ryan Neph       2021-02-02  299  	int handle;
a86f25518e3ab7 Michał Mirosław 2017-08-31  300  	char dbgname[TASK_COMM_LEN];
62fb7a5e10962a Gerd Hoffmann   2014-10-28  301  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  302  	/* can't create contexts without 3d renderer */
62fb7a5e10962a Gerd Hoffmann   2014-10-28  303  	if (!vgdev->has_virgl_3d)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  304  		return 0;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  305  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  306  	/* allocate a virt GPU context for this opener */
62fb7a5e10962a Gerd Hoffmann   2014-10-28  307  	vfpriv = kzalloc(sizeof(*vfpriv), GFP_KERNEL);
62fb7a5e10962a Gerd Hoffmann   2014-10-28  308  	if (!vfpriv)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  309  		return -ENOMEM;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  310  
a86f25518e3ab7 Michał Mirosław 2017-08-31  311  	get_task_comm(dbgname, current);
62fb7a5e10962a Gerd Hoffmann   2014-10-28  312  
b182d75023cbf6 Ryan Neph       2021-02-02  313  	handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL);
b182d75023cbf6 Ryan Neph       2021-02-02  314  	if (handle < 0)
b182d75023cbf6 Ryan Neph       2021-02-02 @315  		return handle;

kfree(vfpriv);

b182d75023cbf6 Ryan Neph       2021-02-02  316  
b182d75023cbf6 Ryan Neph       2021-02-02  317  	vfpriv->ctx_id = handle + 1;
b182d75023cbf6 Ryan Neph       2021-02-02  318  
b182d75023cbf6 Ryan Neph       2021-02-02  319  	/* create the default context without context_init flags for
b182d75023cbf6 Ryan Neph       2021-02-02  320  	 * back-compatibility
b182d75023cbf6 Ryan Neph       2021-02-02  321  	 */
b182d75023cbf6 Ryan Neph       2021-02-02  322  	virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, 0, strlen(dbgname),
b182d75023cbf6 Ryan Neph       2021-02-02  323  				      dbgname);
b182d75023cbf6 Ryan Neph       2021-02-02  324  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  325  	file->driver_priv = vfpriv;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  326  	return 0;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  327  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org 

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35549 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [kbuild] [chrome-os:chromeos-5.4 11/13] drivers/gpu/drm/virtio/virtgpu_kms.c:315 virtio_gpu_driver_open() warn: possible memory leak of 'vfpriv'
Date: Fri, 19 Mar 2021 11:18:00 +0300	[thread overview]
Message-ID: <20210319081800.GE21246@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3445 bytes --]

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel  chromeos-5.4
head:   aaac331bb0ff1bdb6ca7d9f12634a7028df6addc
commit: b182d75023cbf6ff0ab079ac0377399d6096d7c2 [11/13] CHROMIUM: drm/virtio: implement context init: support init ioctl
config: i386-randconfig-m021-20210318 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/virtio/virtgpu_kms.c:315 virtio_gpu_driver_open() warn: possible memory leak of 'vfpriv'

vim +/vfpriv +315 drivers/gpu/drm/virtio/virtgpu_kms.c

62fb7a5e10962a Gerd Hoffmann   2014-10-28  295  int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  296  {
62fb7a5e10962a Gerd Hoffmann   2014-10-28  297  	struct virtio_gpu_device *vgdev = dev->dev_private;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  298  	struct virtio_gpu_fpriv *vfpriv;
b182d75023cbf6 Ryan Neph       2021-02-02  299  	int handle;
a86f25518e3ab7 Michał Mirosław 2017-08-31  300  	char dbgname[TASK_COMM_LEN];
62fb7a5e10962a Gerd Hoffmann   2014-10-28  301  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  302  	/* can't create contexts without 3d renderer */
62fb7a5e10962a Gerd Hoffmann   2014-10-28  303  	if (!vgdev->has_virgl_3d)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  304  		return 0;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  305  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  306  	/* allocate a virt GPU context for this opener */
62fb7a5e10962a Gerd Hoffmann   2014-10-28  307  	vfpriv = kzalloc(sizeof(*vfpriv), GFP_KERNEL);
62fb7a5e10962a Gerd Hoffmann   2014-10-28  308  	if (!vfpriv)
62fb7a5e10962a Gerd Hoffmann   2014-10-28  309  		return -ENOMEM;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  310  
a86f25518e3ab7 Michał Mirosław 2017-08-31  311  	get_task_comm(dbgname, current);
62fb7a5e10962a Gerd Hoffmann   2014-10-28  312  
b182d75023cbf6 Ryan Neph       2021-02-02  313  	handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL);
b182d75023cbf6 Ryan Neph       2021-02-02  314  	if (handle < 0)
b182d75023cbf6 Ryan Neph       2021-02-02 @315  		return handle;

kfree(vfpriv);

b182d75023cbf6 Ryan Neph       2021-02-02  316  
b182d75023cbf6 Ryan Neph       2021-02-02  317  	vfpriv->ctx_id = handle + 1;
b182d75023cbf6 Ryan Neph       2021-02-02  318  
b182d75023cbf6 Ryan Neph       2021-02-02  319  	/* create the default context without context_init flags for
b182d75023cbf6 Ryan Neph       2021-02-02  320  	 * back-compatibility
b182d75023cbf6 Ryan Neph       2021-02-02  321  	 */
b182d75023cbf6 Ryan Neph       2021-02-02  322  	virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, 0, strlen(dbgname),
b182d75023cbf6 Ryan Neph       2021-02-02  323  				      dbgname);
b182d75023cbf6 Ryan Neph       2021-02-02  324  
62fb7a5e10962a Gerd Hoffmann   2014-10-28  325  	file->driver_priv = vfpriv;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  326  	return 0;
62fb7a5e10962a Gerd Hoffmann   2014-10-28  327  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org 

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35549 bytes --]

             reply	other threads:[~2021-03-19  8:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  8:18 Dan Carpenter [this message]
2021-03-19  8:18 ` [kbuild] [chrome-os:chromeos-5.4 11/13] drivers/gpu/drm/virtio/virtgpu_kms.c:315 virtio_gpu_driver_open() warn: possible memory leak of 'vfpriv' Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-03-19  8:09 kernel test robot

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=20210319081800.GE21246@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.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.