add KASSERT()s to ensure aprint_*_dev() and aprint_*_ifp() is not called

with NULL dv or ifp respectively

related to PR kern/53789
This commit is contained in:
jdolecek 2019-01-14 19:21:54 +00:00
parent 4d0870e51c
commit 54f8a68ddf
1 changed files with 22 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_prf.c,v 1.175 2019/01/07 13:09:48 martin Exp $ */
/* $NetBSD: subr_prf.c,v 1.176 2019/01/14 19:21:54 jdolecek Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.175 2019/01/07 13:09:48 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.176 2019/01/14 19:21:54 jdolecek Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@ -808,6 +808,8 @@ aprint_normal_dev(device_t dv, const char *fmt, ...)
{
va_list ap;
KASSERT(dv != NULL);
va_start(ap, fmt);
aprint_normal_internal(device_xname(dv), fmt, ap);
va_end(ap);
@ -818,6 +820,8 @@ aprint_normal_ifnet(struct ifnet *ifp, const char *fmt, ...)
{
va_list ap;
KASSERT(ifp != NULL);
va_start(ap, fmt);
aprint_normal_internal(ifp->if_xname, fmt, ap);
va_end(ap);
@ -885,6 +889,8 @@ aprint_error_dev(device_t dv, const char *fmt, ...)
{
va_list ap;
KASSERT(dv != NULL);
va_start(ap, fmt);
aprint_error_internal(device_xname(dv), fmt, ap);
va_end(ap);
@ -895,6 +901,8 @@ aprint_error_ifnet(struct ifnet *ifp, const char *fmt, ...)
{
va_list ap;
KASSERT(ifp != NULL);
va_start(ap, fmt);
aprint_error_internal(ifp->if_xname, fmt, ap);
va_end(ap);
@ -934,6 +942,8 @@ aprint_naive_dev(device_t dv, const char *fmt, ...)
{
va_list ap;
KASSERT(dv != NULL);
va_start(ap, fmt);
aprint_naive_internal(device_xname(dv), fmt, ap);
va_end(ap);
@ -944,6 +954,8 @@ aprint_naive_ifnet(struct ifnet *ifp, const char *fmt, ...)
{
va_list ap;
KASSERT(ifp != NULL);
va_start(ap, fmt);
aprint_naive_internal(ifp->if_xname, fmt, ap);
va_end(ap);
@ -988,6 +1000,8 @@ aprint_verbose_dev(device_t dv, const char *fmt, ...)
{
va_list ap;
KASSERT(dv != NULL);
va_start(ap, fmt);
aprint_verbose_internal(device_xname(dv), fmt, ap);
va_end(ap);
@ -998,6 +1012,8 @@ aprint_verbose_ifnet(struct ifnet *ifp, const char *fmt, ...)
{
va_list ap;
KASSERT(ifp != NULL);
va_start(ap, fmt);
aprint_verbose_internal(ifp->if_xname, fmt, ap);
va_end(ap);
@ -1036,6 +1052,8 @@ aprint_debug_dev(device_t dv, const char *fmt, ...)
{
va_list ap;
KASSERT(dv != NULL);
va_start(ap, fmt);
aprint_debug_internal(device_xname(dv), fmt, ap);
va_end(ap);
@ -1046,6 +1064,8 @@ aprint_debug_ifnet(struct ifnet *ifp, const char *fmt, ...)
{
va_list ap;
KASSERT(ifp != NULL);
va_start(ap, fmt);
aprint_debug_internal(ifp->if_xname, fmt, ap);
va_end(ap);