aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/mei/debugfs.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 2399b3181e6c..ca2a12d702a9 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -29,20 +29,28 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,
29{ 29{
30 struct mei_device *dev = fp->private_data; 30 struct mei_device *dev = fp->private_data;
31 struct mei_me_client *me_cl; 31 struct mei_me_client *me_cl;
32 const size_t bufsz = 1024; 32 size_t bufsz = 1;
33 char *buf = kzalloc(bufsz, GFP_KERNEL); 33 char *buf;
34 int i = 0; 34 int i = 0;
35 int pos = 0; 35 int pos = 0;
36 int ret; 36 int ret;
37 37
38 if (!buf) 38#define HDR " |id|addr| UUID |con|msg len|\n"
39 return -ENOMEM;
40
41 pos += scnprintf(buf + pos, bufsz - pos,
42 " |id|addr| UUID |con|msg len|\n");
43 39
44 mutex_lock(&dev->device_lock); 40 mutex_lock(&dev->device_lock);
45 41
42 list_for_each_entry(me_cl, &dev->me_clients, list)
43 bufsz++;
44
45 bufsz *= sizeof(HDR) + 1;
46 buf = kzalloc(bufsz, GFP_KERNEL);
47 if (!buf) {
48 mutex_unlock(&dev->device_lock);
49 return -ENOMEM;
50 }
51
52 pos += scnprintf(buf + pos, bufsz - pos, HDR);
53
46 /* if the driver is not enabled the list won't be consistent */ 54 /* if the driver is not enabled the list won't be consistent */
47 if (dev->dev_state != MEI_DEV_ENABLED) 55 if (dev->dev_state != MEI_DEV_ENABLED)
48 goto out; 56 goto out;