diff options
author | adrian <adrian@FreeBSD.org> | 2012-04-13 04:22:42 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2012-04-13 04:22:42 +0000 |
commit | 2c73480574915804b0cd8d6e9b6b52e86aa4d00b (patch) | |
tree | d3d06810902e22f9b45162b6be94cab3703357a9 /sys/kern/subr_firmware.c | |
parent | 4b63f702b77fee250d25c5caf39cd7a770789f07 (diff) | |
download | FreeBSD-src-2c73480574915804b0cd8d6e9b6b52e86aa4d00b.zip FreeBSD-src-2c73480574915804b0cd8d6e9b6b52e86aa4d00b.tar.gz |
Use strdup() on the name (and free it when it's done) so non-static names
can be used in firmware_register().
Diffstat (limited to 'sys/kern/subr_firmware.c')
-rw-r--r-- | sys/kern/subr_firmware.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/subr_firmware.c b/sys/kern/subr_firmware.c index 9a1ec3f..2081987 100644 --- a/sys/kern/subr_firmware.c +++ b/sys/kern/subr_firmware.c @@ -175,6 +175,9 @@ firmware_register(const char *imagename, const void *data, size_t datasize, 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, const void *data, size_t datasize, 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 *imagename) 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 *imagename) * 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; |