Coverity CID 5019: Check before deref.

This commit is contained in:
christos 2008-05-24 16:49:30 +00:00
parent f4569a9440
commit 2847938186
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_subr.c,v 1.187 2008/05/02 13:02:31 ad Exp $ */
/* $NetBSD: kern_subr.c,v 1.188 2008/05/24 16:49:30 christos Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.187 2008/05/02 13:02:31 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.188 2008/05/24 16:49:30 christos Exp $");
#include "opt_ddb.h"
#include "opt_md.h"
@ -960,7 +960,10 @@ setroot(struct device *bootdv, int bootpartition)
*/
rootdv = bootdv;
majdev = devsw_name2blk(device_xname(bootdv), NULL, 0);
if (bootdv)
majdev = devsw_name2blk(device_xname(bootdv), NULL, 0);
else
majdev = -1;
if (majdev >= 0) {
/*
* Root is on a disk. `bootpartition' is root,