Skip to content

Commit d340014

Browse files
committed
Correctly call vfree
1 parent 32b874e commit d340014

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

kernel-open/common/inc/nv-linux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static inline void *nv_vmalloc(unsigned long size)
506506
static inline void nv_vfree(void *ptr, NvU64 size)
507507
{
508508
NV_MEMDBG_REMOVE(ptr, size);
509-
vfree(ptr);
509+
vfree(ptr, size);
510510
}
511511

512512
static inline void *nv_ioremap(NvU64 phys, NvU64 size)

kernel-open/nvidia-modeset/nvidia-modeset-linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void nvkms_free(void *ptr, size_t size)
260260
if (size <= KMALLOC_LIMIT) {
261261
kfree(ptr);
262262
} else {
263-
vfree(ptr);
263+
vfree(ptr, size);
264264
}
265265
}
266266

kernel-open/nvidia-uvm/nv-kthread-q-selftest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static int _multithreaded_q_kthread_function(void *args)
241241

242242
done:
243243
if (q_items)
244-
vfree(q_items);
244+
vfree(q_items, alloc_size);
245245

246246
while (!kthread_should_stop())
247247
schedule();

kernel-open/nvidia-uvm/uvm_kvmalloc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,20 @@ void *__uvm_kvmalloc_zero(size_t size, const char *file, int line, const char *f
297297

298298
void uvm_kvfree(void *p)
299299
{
300+
uvm_vmalloc_hdr_t *hdr = NULL;
301+
300302
if (!p)
301303
return;
302304

303305
if (uvm_leak_checker)
304306
alloc_tracking_remove(p);
305307

306-
if (is_vmalloc_addr(p))
307-
vfree(get_hdr(p));
308-
else
308+
if (is_vmalloc_addr(p)){
309+
hdr = get_hdr(p);
310+
vfree(hdr, hdr->alloc_size);
311+
} else {
309312
kfree(p);
313+
}
310314
}
311315

312316
// Handle reallocs of kmalloc-based allocations
@@ -334,7 +338,7 @@ static void *realloc_from_vmalloc(void *p, size_t new_size)
334338
void *new_p;
335339

336340
if (new_size == 0) {
337-
vfree(old_hdr);
341+
vfree(old_hdr, old_hdr->alloc_size);
338342
return ZERO_SIZE_PTR; // What krealloc returns for this case
339343
}
340344

@@ -348,7 +352,7 @@ static void *realloc_from_vmalloc(void *p, size_t new_size)
348352
return NULL;
349353

350354
memcpy(new_p, p, min(new_size, old_hdr->alloc_size));
351-
vfree(old_hdr);
355+
vfree(old_hdr, old_hdr->alloc_size);
352356
return new_p;
353357
}
354358

kernel-open/nvidia/linux_nvswitch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ _nvswitch_os_free
711711

712712
if (is_vmalloc_addr(ptr))
713713
{
714-
vfree(ptr);
714+
vfree(ptr, -1ull);
715715
}
716716
else
717717
{

0 commit comments

Comments
 (0)