Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Fix undefined behaviors found by kUBSan.



details:   https://anonhg.NetBSD.org/src/rev/45549c9f3288
branches:  trunk
changeset: 955971:45549c9f3288
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Oct 18 11:51:08 2020 +0000

description:
Fix undefined behaviors found by kUBSan.
Tested on VirtualBox with amd64 kernel.

diffstat:

 sys/dev/ic/ac97.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 10e900a645c2 -r 45549c9f3288 sys/dev/ic/ac97.c
--- a/sys/dev/ic/ac97.c Sun Oct 18 11:49:47 2020 +0000
+++ b/sys/dev/ic/ac97.c Sun Oct 18 11:51:08 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ac97.c,v 1.99 2019/11/28 05:07:27 isaki Exp $ */
+/*      $NetBSD: ac97.c,v 1.100 2020/10/18 11:51:08 rin Exp $ */
 /*     $OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $       */
 
 /*
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.99 2019/11/28 05:07:27 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.100 2020/10/18 11:51:08 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1315,7 +1315,7 @@
 
        mutex_exit(as->lock);
 
-       id = (id1 << 16) | id2;
+       id = ((uint32_t)id1 << 16) | id2;
        aprint_normal_dev(sc_dev, "ac97: ");
 
        for (i = 0; ; i++) {
@@ -1696,7 +1696,8 @@
                if (name)
                        strcpy(dip->label.name, name);
 
-               memcpy(&dip->un, si->info, si->info_size);
+               if (si->info)
+                       memcpy(&dip->un, si->info, si->info_size);
 
                /* Set the delta for volume sources */
                if (dip->type == AUDIO_MIXER_VALUE)



Home | Main Index | Thread Index | Old Index