drivers/gpu/drm/vboxvideo/vbox_main.c:146 vbox_hw_init() warn: 'vbox->guest_heap' not released on lines: 126.

From: Dan Carpenter
Date: Tue Oct 06 2020 - 13:17:51 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 472e5b056f000a778abb41f1e443de58eb259783
commit: 8558de401b5fbbfb1df96d6986bba3c79cd47401 drm/vboxvideo: use managed pci functions
config: i386-randconfig-m021-20201002 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
drivers/gpu/drm/vboxvideo/vbox_main.c:146 vbox_hw_init() warn: 'vbox->guest_heap' not released on lines: 126.

vim +146 drivers/gpu/drm/vboxvideo/vbox_main.c

d46709094deb69 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2018-09-18 107 int vbox_hw_init(struct vbox_private *vbox)
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 108 {
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 109 int ret = -ENOMEM;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 110
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 111 vbox->full_vram_size = inl(VBE_DISPI_IOPORT_DATA);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 112 vbox->any_pitch = vbox_check_supported(VBE_DISPI_ID_ANYX);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 113
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 114 DRM_INFO("VRAM %08x\n", vbox->full_vram_size);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 115
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 116 /* Map guest-heap at end of vram */
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 117 vbox->guest_heap =
01648890f336a3 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2018-09-18 118 pci_iomap_range(vbox->ddev.pdev, 0, GUEST_HEAP_OFFSET(vbox),
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 119 GUEST_HEAP_SIZE);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 120 if (!vbox->guest_heap)
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 121 return -ENOMEM;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 122
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 123 /* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 124 vbox->guest_pool = gen_pool_create(4, -1);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 125 if (!vbox->guest_pool)
8558de401b5fbb drivers/gpu/drm/vboxvideo/vbox_main.c Daniel Vetter 2020-04-15 126 return -ENOMEM;

Need to unmap vbox->guest_heap on error. Probably all error paths?

dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 127
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 128 ret = gen_pool_add_virt(vbox->guest_pool,
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 129 (unsigned long)vbox->guest_heap,
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 130 GUEST_HEAP_OFFSET(vbox),
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 131 GUEST_HEAP_USABLE_SIZE, -1);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 132 if (ret)
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 133 goto err_destroy_guest_pool;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 134
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 135 ret = hgsmi_test_query_conf(vbox->guest_pool);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 136 if (ret) {
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 137 DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 138 goto err_destroy_guest_pool;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 139 }
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 140
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 141 /* Reduce available VRAM size to reflect the guest heap. */
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 142 vbox->available_vram_size = GUEST_HEAP_OFFSET(vbox);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 143 /* Linux drm represents monitors as a 32-bit array. */
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 144 hgsmi_query_conf(vbox->guest_pool, VBOX_VBVA_CONF32_MONITOR_COUNT,
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 145 &vbox->num_crtcs);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 @146 vbox->num_crtcs = clamp_t(u32, vbox->num_crtcs, 1, VBOX_MAX_SCREENS);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 147
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 148 if (!have_hgsmi_mode_hints(vbox)) {
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 149 ret = -ENOTSUPP;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 150 goto err_destroy_guest_pool;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 151 }
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 152
01648890f336a3 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2018-09-18 153 vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 154 sizeof(struct vbva_modehint),
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 155 GFP_KERNEL);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 156 if (!vbox->last_mode_hints) {
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 157 ret = -ENOMEM;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 158 goto err_destroy_guest_pool;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 159 }
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 160
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 161 ret = vbox_accel_init(vbox);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 162 if (ret)
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 163 goto err_destroy_guest_pool;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 164
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 165 return 0;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 166
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 167 err_destroy_guest_pool:
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 168 gen_pool_destroy(vbox->guest_pool);
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 169 return ret;
dd55d44f408419 drivers/staging/vboxvideo/vbox_main.c Hans de Goede 2017-07-06 170 }

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

Attachment: .config.gz
Description: application/gzip