{
        struct wl1271 *wl = file->private_data;
        int res = 0;
-       char buf[1024];
+       ssize_t ret;
+       char *buf;
+
+#define DRIVER_STATE_BUF_LEN 1024
+
+       buf = kmalloc(DRIVER_STATE_BUF_LEN, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
 
        mutex_lock(&wl->mutex);
 
 #define DRIVER_STATE_PRINT(x, fmt)   \
-       (res += scnprintf(buf + res, sizeof(buf) - res,\
+       (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
                          #x " = " fmt "\n", wl->x))
 
 #define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld")
 #undef DRIVER_STATE_PRINT_LHEX
 #undef DRIVER_STATE_PRINT_STR
 #undef DRIVER_STATE_PRINT
+#undef DRIVER_STATE_BUF_LEN
 
        mutex_unlock(&wl->mutex);
 
-       return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+       ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
+       kfree(buf);
+       return ret;
 }
 
 static const struct file_operations driver_state_ops = {