Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Added check of pointer for allocated memory befo...



details:   https://anonhg.NetBSD.org/src/rev/c0326520f414
branches:  trunk
changeset: 374015:c0326520f414
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Fri Mar 24 13:32:19 2023 +0000

description:
Added check of pointer for allocated memory before release of resource

diffstat:

 sys/dev/pci/vioscsi.c |  7 +++----
 sys/dev/pci/virtio.c  |  7 +++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r a8d8921fd4ba -r c0326520f414 sys/dev/pci/vioscsi.c
--- a/sys/dev/pci/vioscsi.c     Fri Mar 24 13:16:15 2023 +0000
+++ b/sys/dev/pci/vioscsi.c     Fri Mar 24 13:32:19 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $   */
+/*     $NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $   */
 /*     $OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.33 2023/03/24 13:32:19 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -206,8 +206,7 @@ err:
                vioscsi_free_reqs(sc, vsc);
 
        for (i=0; i < __arraycount(sc->sc_vqs); i++) {
-               if (sc->sc_vqs[i].vq_num > 0)
-                       virtio_free_vq(vsc, &sc->sc_vqs[i]);
+               virtio_free_vq(vsc, &sc->sc_vqs[i]);
        }
 
        virtio_child_attach_failed(vsc);
diff -r a8d8921fd4ba -r c0326520f414 sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Fri Mar 24 13:16:15 2023 +0000
+++ b/sys/dev/pci/virtio.c      Fri Mar 24 13:32:19 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio.c,v 1.67 2023/03/23 03:55:11 yamaguchi Exp $    */
+/*     $NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.67 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.68 2023/03/24 13:32:19 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -898,6 +898,9 @@ virtio_free_vq(struct virtio_softc *sc, 
        struct vq_entry *qe;
        int i = 0;
 
+       if (vq->vq_vaddr == NULL)
+               return 0;
+
        /* device must be already deactivated */
        /* confirm the vq is empty */
        SIMPLEQ_FOREACH(qe, &vq->vq_freelist, qe_list) {



Home | Main Index | Thread Index | Old Index