NetBSD Problem Report #56055
From www@netbsd.org Sat Mar 13 11:27:47 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id EAAD51A923B
for <gnats-bugs@gnats.NetBSD.org>; Sat, 13 Mar 2021 11:27:46 +0000 (UTC)
Message-Id: <20210313112745.5AA281A923E@mollari.NetBSD.org>
Date: Sat, 13 Mar 2021 11:27:45 +0000 (UTC)
From: jmcneill@invisible.ca
Reply-To: jmcneill@invisible.ca
To: gnats-bugs@NetBSD.org
Subject: vmem: import/release/xrelease mismatch between docs/signatures/implementation
X-Send-Pr-Version: www-1.0
>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.
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.