Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb aubtfwl(4): Use kmem_asprintf() for firmware fil...
details: https://anonhg.NetBSD.org/src/rev/394efa139e76
branches: trunk
changeset: 933764:394efa139e76
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sat May 30 17:19:45 2020 +0000
description:
aubtfwl(4): Use kmem_asprintf() for firmware file name creation.
A MAXPATHLEN+1 array of char on stack is "too much".
diffstat:
sys/dev/usb/aubtfwl.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diffs (58 lines):
diff -r 4812e84f3e97 -r 394efa139e76 sys/dev/usb/aubtfwl.c
--- a/sys/dev/usb/aubtfwl.c Sat May 30 17:18:22 2020 +0000
+++ b/sys/dev/usb/aubtfwl.c Sat May 30 17:19:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aubtfwl.c,v 1.9 2020/03/14 02:35:33 christos Exp $ */
+/* $NetBSD: aubtfwl.c,v 1.10 2020/05/30 17:19:45 jakllsch Exp $ */
/*
* Copyright (c) 2011 Jonathan A. Kollasch
@@ -27,9 +27,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aubtfwl.c,v 1.9 2020/03/14 02:35:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aubtfwl.c,v 1.10 2020/05/30 17:19:45 jakllsch Exp $");
#include <sys/param.h>
+#include <sys/kmem.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usbdi.h>
@@ -272,7 +273,7 @@
aubtfwl_attach_hook(device_t self)
{
struct aubtfwl_softc * const sc = device_private(self);
- char firmware_name[MAXPATHLEN+1];
+ char *fw_name;
struct ar3k_version ver;
uint8_t state;
int clock = 0;
@@ -292,9 +293,10 @@
aprint_verbose_dev(self, "state is 0x%02x\n", state);
if (!(state & AR3K_STATE_IS_PATCHED)) {
- snprintf(firmware_name, sizeof(firmware_name),
- "ar3k/AthrBT_0x%08x.dfu", ver.rom);
- error = aubtfwl_firmware_load(self, firmware_name);
+ fw_name = kmem_asprintf("ar3k/AthrBT_0x%08x.dfu",
+ ver.rom);
+ error = aubtfwl_firmware_load(self, fw_name);
+ kmem_strfree(fw_name);
if (error)
return;
@@ -312,9 +314,10 @@
break;
}
- snprintf(firmware_name, sizeof(firmware_name),
- "ar3k/ramps_0x%08x_%d.dfu", ver.rom, clock);
- aubtfwl_firmware_load(self, firmware_name);
+ fw_name = kmem_asprintf("ar3k/ramps_0x%08x_%d.dfu",
+ ver.rom, clock);
+ aubtfwl_firmware_load(self, fw_name);
+ kmem_strfree(fw_name);
if ((state & AR3K_STATE_MODE_MASK) != AR3K_STATE_MODE_NORMAL) {
error = aubtfwl_send_command(sc, AR3K_SET_NORMAL_MODE);
Home |
Main Index |
Thread Index |
Old Index