Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb umcs(4): Avoid using uninitialized data if regis...



details:   https://anonhg.NetBSD.org/src/rev/dcb74c66cba7
branches:  trunk
changeset: 365702:dcb74c66cba7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Apr 19 01:35:28 2022 +0000

description:
umcs(4): Avoid using uninitialized data if register read fails.

Reported-by: syzbot+511b32f415150b469250%syzkaller.appspotmail.com@localhost

diffstat:

 sys/dev/usb/umcs.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 0abe0319b08a -r dcb74c66cba7 sys/dev/usb/umcs.c
--- a/sys/dev/usb/umcs.c        Tue Apr 19 01:34:52 2022 +0000
+++ b/sys/dev/usb/umcs.c        Tue Apr 19 01:35:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umcs.c,v 1.18 2022/02/09 07:32:33 mrg Exp $ */
+/* $NetBSD: umcs.c,v 1.19 2022/04/19 01:35:28 riastradh Exp $ */
 /* $FreeBSD: head/sys/dev/usb/serial/umcs.c 260559 2014-01-12 11:44:28Z hselasky $ */
 
 /*-
@@ -41,7 +41,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.18 2022/02/09 07:32:33 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.19 2022/04/19 01:35:28 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -226,8 +226,8 @@
         *
         * Also, see notes in header file for these constants.
         */
-       umcs7840_get_reg(sc, MCS7840_DEV_REG_GPIO, &data);
-       if (data & MCS7840_DEV_GPIO_4PORTS) {
+       error = umcs7840_get_reg(sc, MCS7840_DEV_REG_GPIO, &data);
+       if (error == 0 && (data & MCS7840_DEV_GPIO_4PORTS) != 0) {
                sc->sc_numports = 4;
                /* physical port no are : 0, 1, 2, 3 */
        } else {



Home | Main Index | Thread Index | Old Index