svn commit: r282725 - head/sys/dev/usb/video
Hans Petter Selasky
hselasky at FreeBSD.org
Sun May 10 12:45:22 UTC 2015
Author: hselasky
Date: Sun May 10 12:45:21 2015
New Revision: 282725
URL: https://svnweb.freebsd.org/changeset/base/282725
Log:
Put recycle pointer in own memory area which is not mmap'able.
Modified:
head/sys/dev/usb/video/udl.c
Modified: head/sys/dev/usb/video/udl.c
==============================================================================
--- head/sys/dev/usb/video/udl.c Sun May 10 12:41:34 2015 (r282724)
+++ head/sys/dev/usb/video/udl.c Sun May 10 12:45:21 2015 (r282725)
@@ -203,12 +203,14 @@ udl_buffer_alloc(uint32_t size)
}
mtx_unlock(&udl_buffer_mtx);
if (buf != NULL) {
+ uint8_t *ptr = ((uint8_t *)buf) - size;
/* wipe and recycle buffer */
- memset(buf, 0, size);
- return (buf);
+ memset(ptr, 0, size);
+ /* return buffer pointer */
+ return (ptr);
}
/* allocate new buffer */
- return (malloc(size, M_USB_DL, M_WAITOK | M_ZERO));
+ return (malloc(size + sizeof(*buf), M_USB_DL, M_WAITOK | M_ZERO));
}
static void
@@ -216,9 +218,11 @@ udl_buffer_free(void *_buf, uint32_t siz
{
struct udl_buffer *buf;
- buf = (struct udl_buffer *)_buf;
- if (buf == NULL)
+ /* check for NULL pointer */
+ if (_buf == NULL)
return;
+ /* compute pointer to recycle list */
+ buf = (struct udl_buffer *)(((uint8_t *)_buf) + size);
/*
* Memory mapped buffers should never be freed.
More information about the svn-src-head
mailing list