From 2847938186cc955e02d489f5bc9db7310f26f345 Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 24 May 2008 16:49:30 +0000 Subject: [PATCH] Coverity CID 5019: Check before deref. --- sys/kern/kern_subr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 4e12ceeddadd..d9d0172ec438 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -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 -__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,