NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/56055: vmem: import/release/xrelease mismatch between docs/signatures/implementation



>Number:         56055
>Category:       kern
>Synopsis:       vmem: import/release/xrelease mismatch between docs/signatures/implementation
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 13 11:30:00 +0000 2021
>Originator:     Jared McNeill
>Release:        -current
>Organization:
NetBSD
>Environment:
NetBSD -current
>Description:
The man page for vmem shows vmem_create with callbacks that takes private data "void *" as first parameter:

     vmem_t *
     vmem_create(const char *name, vmem_addr_t base, vmem_size_t size,
         vmem_size_t quantum,
         int (*allocfn)(void *, vmem_size_t, vm_flag_t, vmem_addr_t *),
         void (*freefn)(void *, vmem_addr_t, vmem_size_t), void *arg,
         vmem_size_t qcache_max, vm_flag_t flags, int ipl);

The prototype in sys/vmem.h is:

    vmem_t *        vmem_create(const char *, vmem_addr_t, vmem_size_t, vmem_size_t,
                        vmem_import_t *, vmem_release_t *, vmem_t *, vmem_size_t,   
                        vm_flag_t, int);                                            

Where vmem_import_t is defined with a different type (vmem_t *) for the first arg:

    typedef int     (vmem_import_t)(vmem_t *, vmem_size_t, vm_flag_t,               
                        vmem_addr_t *);                                             


The actual call to the callback in vmem_import passes the private data as the first argument:

    rc = (vm->vm_importfn)(vm->vm_arg, size, flags, &addr);

So I think the vmem_import_t (and vmem_release_t and vmem_ximport_t) define needs to be fixed.
>How-To-Repeat:
Code inspection.
>Fix:
Change vmem_import_t / vmem_release_t / vmem_ximport_t signatures and adjust callers.



Home | Main Index | Thread Index | Old Index