Skip to content

Commit c99f895

Browse files
author
Luciano Coelho
committed
wl12xx: alloc buffer in driver_state_read to prevent compilation warning
When compiling wl12xx for x86, there was a warning complaining about the size of the buffer we were allocating in the stack: drivers/net/wireless/wl12xx/debugfs.c: In function 'driver_state_read': drivers/net/wireless/wl12xx/debugfs.c:380:1: warning: the frame size of 1040 bytes is larger than 1024 bytes To prevent this, allocate the buffer in the heap instead. Signed-off-by: Luciano Coelho <coelho@ti.com>
1 parent ef18706 commit c99f895

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎drivers/net/wireless/wl12xx/debugfs.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,19 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
317317
{
318318
struct wl1271 *wl = file->private_data;
319319
int res = 0;
320-
char buf[1024];
320+
ssize_t ret;
321+
char *buf;
322+
323+
#define DRIVER_STATE_BUF_LEN 1024
324+
325+
buf = kmalloc(DRIVER_STATE_BUF_LEN, GFP_KERNEL);
326+
if (!buf)
327+
return -ENOMEM;
321328

322329
mutex_lock(&wl->mutex);
323330

324331
#define DRIVER_STATE_PRINT(x, fmt) \
325-
(res += scnprintf(buf + res, sizeof(buf) - res,\
332+
(res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
326333
#x " = " fmt "\n", wl->x))
327334

328335
#define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld")
@@ -373,10 +380,13 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
373380
#undef DRIVER_STATE_PRINT_LHEX
374381
#undef DRIVER_STATE_PRINT_STR
375382
#undef DRIVER_STATE_PRINT
383+
#undef DRIVER_STATE_BUF_LEN
376384

377385
mutex_unlock(&wl->mutex);
378386

379-
return simple_read_from_buffer(user_buf, count, ppos, buf, res);
387+
ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
388+
kfree(buf);
389+
return ret;
380390
}
381391

382392
static const struct file_operations driver_state_ops = {

0 commit comments

Comments
 (0)