Index | Thread | Search

From:
Kirill A. Korinsky <kirill@korins.ky>
Subject:
sys/video: cleanup pointers to detached device
To:
OpenBSD tech <tech@openbsd.org>
Cc:
Marcus Glocker <mglocker@openbsd.org>
Date:
Wed, 12 Mar 2025 11:08:55 +0100

Download raw body.

Thread
  • Kirill A. Korinsky:

    sys/video: cleanup pointers to detached device

tech@,

Here a diff which drop pointers to sc->hw_if, sc->hw_hdl and sc->sc_dev
in detach, which prevents user application to call ioctl() on already
detached device.

Ok?

Index: sys/dev/video.c
===================================================================
RCS file: /home/cvs/src/sys/dev/video.c,v
diff -u -p -r1.59 video.c
--- sys/dev/video.c	16 Dec 2024 21:22:51 -0000	1.59
+++ sys/dev/video.c	12 Mar 2025 08:52:29 -0000
@@ -644,6 +648,10 @@ videodetach(struct device *self, int fla
 	klist_free(&sc->sc_rklist);
 
 	free(sc->sc_fbuffer, M_DEVBUF, sc->sc_fbufferlen);
+
+	sc->hw_if = NULL;
+	sc->hw_hdl = NULL;
+	sc->sc_dev = NULL;
 
 	return (0);
 }