Avoid NULL deref in case no bufq has been set.

This commit is contained in:
mlelstv 2016-06-26 07:22:15 +00:00
parent b66056e8a0
commit f16f2cde63
1 changed files with 7 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dksubr.c,v 1.86 2016/01/04 10:02:15 mlelstv Exp $ */
/* $NetBSD: dksubr.c,v 1.87 2016/06/26 07:22:15 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.86 2016/01/04 10:02:15 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.87 2016/06/26 07:22:15 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -658,12 +658,13 @@ dk_ioctl(struct dk_softc *dksc, dev_t dev,
struct disk_strategy *dks = (void *)data;
mutex_enter(&dksc->sc_iolock);
strlcpy(dks->dks_name, bufq_getstrategyname(dksc->sc_bufq),
sizeof(dks->dks_name));
if (dksc->sc_bufq != NULL)
strlcpy(dks->dks_name, bufq_getstrategyname(dksc->sc_bufq),
sizeof(dks->dks_name));
else
error = EINVAL;
mutex_exit(&dksc->sc_iolock);
dks->dks_paramlen = 0;
return 0;
}
case DIOCSSTRATEGY:
@ -687,8 +688,6 @@ dk_ioctl(struct dk_softc *dksc, dev_t dev,
dksc->sc_bufq = new;
mutex_exit(&dksc->sc_iolock);
bufq_free(old);
return 0;
}
default: