Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic reduce stack usage in bwfm_rx_event_cb(), can use...



details:   https://anonhg.NetBSD.org/src/rev/1f47f9264f18
branches:  trunk
changeset: 933755:1f47f9264f18
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat May 30 14:03:08 2020 +0000

description:
reduce stack usage in bwfm_rx_event_cb(), can use KM_SLEEP because
this is called from workqueue handler (i.e. thread context)

diffstat:

 sys/dev/ic/bwfm.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (29 lines):

diff -r c20d443310e2 -r 1f47f9264f18 sys/dev/ic/bwfm.c
--- a/sys/dev/ic/bwfm.c Sat May 30 13:41:58 2020 +0000
+++ b/sys/dev/ic/bwfm.c Sat May 30 14:03:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.23 2020/05/30 13:41:58 jdolecek Exp $ */
+/* $NetBSD: bwfm.c,v 1.24 2020/05/30 14:03:08 jdolecek Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -2143,12 +2143,15 @@
                        union {
                                struct bwfm_bss_info bss_info;
                                uint8_t padding[BWFM_BSS_INFO_BUFLEN];
-                       } bss_buf;
-                       if (len > sizeof(bss_buf)) {
+                       } *bss_buf;
+                       if (len > sizeof(*bss_buf)) {
                                printf("%s: bss_info buffer too big\n", DEVNAME(sc));
                        } else {
-                               memcpy(&bss_buf, &res->bss_info[i], len);
-                               bwfm_scan_node(sc, &bss_buf.bss_info, len);
+                               bss_buf = kmem_alloc(sizeof(*bss_buf),
+                                   KM_SLEEP);
+                               memcpy(bss_buf, &res->bss_info[i], len);
+                               bwfm_scan_node(sc, &bss_buf->bss_info, len);
+                               kmem_free(bss_buf, sizeof(*bss_buf));
                        }
                        len -= sizeof(*bss) + le32toh(bss->length);
                        bss = (void *)(((uintptr_t)bss) + le32toh(bss->length));



Home | Main Index | Thread Index | Old Index