diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-05-16 12:01:52 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-05-16 12:01:52 +0000 |
commit | fd6a8b6e4f9e65f5ddb29f7906a32457887461c3 (patch) | |
tree | a99e3c110f7aa570c0e9d6c36215cad965c0a967 /sys/dev | |
parent | 84bf8d79fa737caa9da377bd9a319427bf930c1c (diff) |
Free sample buffer on detach. Noted by miod@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/uvideo.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index 35a2d07eee7..43c5bb5d2d9 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.13 2008/05/16 08:01:39 mglocker Exp $ */ +/* $OpenBSD: uvideo.c,v 1.14 2008/05/16 12:01:51 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -87,6 +87,7 @@ usbd_status uvideo_vs_set_probe(struct uvideo_softc *, uint8_t *); usbd_status uvideo_vs_get_probe(struct uvideo_softc *, uint8_t *); usbd_status uvideo_vs_set_commit(struct uvideo_softc *, uint8_t *); usbd_status uvideo_vs_alloc_sample(struct uvideo_softc *); +void uvideo_vs_free_sample(struct uvideo_softc *); usbd_status uvideo_vs_alloc(struct uvideo_softc *); usbd_status uvideo_vs_open(struct uvideo_softc *, struct usb_attach_arg *); void uvideo_vs_start(struct uvideo_softc *); @@ -308,6 +309,8 @@ uvideo_detach(struct device * self, int flags) /* Wait for outstanding requests to complete */ usbd_delay_ms(sc->sc_udev, UVIDEO_NFRAMES_MAX); + uvideo_vs_free_sample(sc); + if (sc->sc_videodev != NULL) rv = config_detach(sc->sc_videodev, flags); @@ -885,7 +888,7 @@ uvideo_vs_alloc_sample(struct uvideo_softc *sc) DPRINTF(1, "%s: %s\n", DEVNAME(sc), __func__); - fb->buf = malloc(32000, M_TEMP, M_NOWAIT); /* XXX find proper size */ + fb->buf = malloc(32000, M_DEVBUF, M_NOWAIT); /* XXX find proper size */ if (fb->buf == NULL) { printf("%s: can't allocate sample buffer!\n", DEVNAME(sc)); return (USBD_NOMEM); @@ -898,6 +901,17 @@ uvideo_vs_alloc_sample(struct uvideo_softc *sc) return (USBD_NORMAL_COMPLETION); } +void +uvideo_vs_free_sample(struct uvideo_softc *sc) +{ + struct uvideo_sample_buffer *fb = &sc->sc_sample_buffer; + + if (fb->buf != NULL) { + free(fb->buf, M_DEVBUF); + fb->buf = NULL; + } +} + usbd_status uvideo_vs_alloc(struct uvideo_softc *sc) { |