From owner-svn-src-all@FreeBSD.ORG Fri Apr 13 04:22:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF8861065672; Fri, 13 Apr 2012 04:22:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BAC848FC08; Fri, 13 Apr 2012 04:22:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3D4MgmU059822; Fri, 13 Apr 2012 04:22:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3D4MglV059820; Fri, 13 Apr 2012 04:22:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201204130422.q3D4MglV059820@svn.freebsd.org> From: Adrian Chadd Date: Fri, 13 Apr 2012 04:22:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234201 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 13 Apr 2012 04:22:42 -0000 Author: adrian Date: Fri Apr 13 04:22:42 2012 New Revision: 234201 URL: http://svn.freebsd.org/changeset/base/234201 Log: Use strdup() on the name (and free it when it's done) so non-static names can be used in firmware_register(). Modified: head/sys/kern/subr_firmware.c Modified: head/sys/kern/subr_firmware.c ============================================================================== --- head/sys/kern/subr_firmware.c Fri Apr 13 04:21:54 2012 (r234200) +++ head/sys/kern/subr_firmware.c Fri Apr 13 04:22:42 2012 (r234201) @@ -175,6 +175,9 @@ firmware_register(const char *imagename, unsigned int version, const struct firmware *parent) { struct priv_fw *match, *frp; + char *str; + + str = strdup(imagename, M_TEMP); mtx_lock(&firmware_mtx); /* @@ -185,16 +188,18 @@ firmware_register(const char *imagename, mtx_unlock(&firmware_mtx); printf("%s: image %s already registered!\n", __func__, imagename); + free(str, M_TEMP); return NULL; } if (frp == NULL) { mtx_unlock(&firmware_mtx); printf("%s: cannot register image %s, firmware table full!\n", __func__, imagename); + free(str, M_TEMP); return NULL; } bzero(frp, sizeof(frp)); /* start from a clean record */ - frp->fw.name = imagename; + frp->fw.name = str; frp->fw.data = data; frp->fw.datasize = datasize; frp->fw.version = version; @@ -230,7 +235,7 @@ firmware_unregister(const char *imagenam err = 0; } else if (fp->refcnt != 0) { /* cannot unregister */ err = EBUSY; - } else { + } else { linker_file_t x = fp->file; /* save value */ /* @@ -238,6 +243,7 @@ firmware_unregister(const char *imagenam * do not forget anything. Then restore 'file' which is * non-null for autoloaded images. */ + free((void *) (uintptr_t) fp->fw.name, M_TEMP); bzero(fp, sizeof(struct priv_fw)); fp->file = x; err = 0;