Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Don't allocate memory and return EFTYPE if sc->sc_b...



details:   https://anonhg.NetBSD.org/src/rev/ecf1829f8c36
branches:  trunk
changeset: 320394:ecf1829f8c36
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jul 04 07:25:47 2018 +0000

description:
Don't allocate memory and return EFTYPE if sc->sc_blobsize==0 to prevent
panic in firmware_malloc().

diffstat:

 sys/kern/kern_cpu.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r d350f893e3aa -r ecf1829f8c36 sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c       Wed Jul 04 03:17:01 2018 +0000
+++ b/sys/kern/kern_cpu.c       Wed Jul 04 07:25:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_cpu.c,v 1.73 2018/03/18 00:51:46 christos Exp $   */
+/*     $NetBSD: kern_cpu.c,v 1.74 2018/07/04 07:25:47 msaitoh Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.73 2018/03/18 00:51:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.74 2018/07/04 07:25:47 msaitoh Exp $");
 
 #include "opt_cpu_ucode.h"
 
@@ -602,6 +602,11 @@
        }
 
        sc->sc_blobsize = firmware_get_size(fwh);
+       if (sc->sc_blobsize == 0) {
+               error = EFTYPE;
+               firmware_close(fwh);
+               goto err0;
+       }
        sc->sc_blob = firmware_malloc(sc->sc_blobsize);
        if (sc->sc_blob == NULL) {
                error = ENOMEM;



Home | Main Index | Thread Index | Old Index