Author: imp Date: Tue Apr 20 20:39:42 2010 New Revision: 206916 URL: http://svn.freebsd.org/changeset/base/206916
Log: Make sure that we free the passed in data message if we don't actually insert it onto the queue. Also, fix a mtx leak if someone turns off devctl while we're processing a messages. MFC after: 5 days Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Tue Apr 20 20:36:38 2010 (r206915) +++ head/sys/kern/subr_bus.c Tue Apr 20 20:39:42 2010 (r206916) @@ -545,15 +545,16 @@ devctl_queue_data(char *data) struct proc *p; if (strlen(data) == 0) - return; + goto out; if (devctl_queue_length == 0) - return; + goto out; n1 = malloc(sizeof(*n1), M_BUS, M_NOWAIT); if (n1 == NULL) - return; + goto out; n1->dei_data = data; mtx_lock(&devsoftc.mtx); if (devctl_queue_length == 0) { + mtx_unlock(&devsoftc.mtx); free(n1->dei_data, M_BUS); free(n1, M_BUS); return; @@ -577,6 +578,14 @@ devctl_queue_data(char *data) psignal(p, SIGIO); PROC_UNLOCK(p); } + return; +out: + /* + * We have to free data on all error paths since the caller + * assumes it will be free'd when this item is dequeued. + */ + free(data, M_BUS); + return; } /** _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"