From owner-svn-src-all@FreeBSD.ORG Sun May 10 12:45:22 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1153CBE6; Sun, 10 May 2015 12:45:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3537196D; Sun, 10 May 2015 12:45:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4ACjLcG010934; Sun, 10 May 2015 12:45:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4ACjL3i010933; Sun, 10 May 2015 12:45:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201505101245.t4ACjL3i010933@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sun, 10 May 2015 12:45:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282725 - head/sys/dev/usb/video X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2015 12:45:22 -0000 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.