changeset 10694:584d721decf9

6881749 fc_get_fcode and fc_set_fcode_error panic on a NULL pointer
author Zach Kissel <Zachary.Kissel@Sun.COM>
date Wed, 30 Sep 2009 14:32:51 -0400
parents aaa91fcac595
children c2dc701391b4
files usr/src/uts/sun4/io/efcode/fcode.c
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/sun4/io/efcode/fcode.c	Wed Sep 30 11:27:15 2009 -0600
+++ b/usr/src/uts/sun4/io/efcode/fcode.c	Wed Sep 30 14:32:51 2009 -0400
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -838,6 +838,15 @@
 	st = fc_states + m;
 	ASSERT(m < fc_max_opens && FC_STATE_ACTIVE(st->state));
 
+	/*
+	 * It's an error if we're not in state FC_STATE_IN_PROGRESS
+	 */
+	if (st->state != FC_STATE_IN_PROGRESS) {
+		cmn_err(CE_CONT, "fc_ioctl: fc_get_fcode: wrong state (%d)\n",
+		    st->state);
+		return (EINVAL);
+	}
+
 	ASSERT(st->req != NULL);
 	rp = st->req->handle;
 
@@ -892,6 +901,16 @@
 	st = fc_states + m;
 	ASSERT(m < fc_max_opens && FC_STATE_ACTIVE(st->state));
 
+	/*
+	 * It's an error if we're not in state FC_STATE_IN_PROGRESS.
+	 */
+	if (st->state != FC_STATE_IN_PROGRESS) {
+		cmn_err(CE_CONT,
+		    "fc_ioctl:fc_set_fcode_error: wrong state (%d)\n",
+		    st->state);
+		return (EINVAL);
+	}
+
 	ASSERT(st->req != NULL);
 	fp = st->req;