bluetooth: debugfs changes use too much stack
Subsystems (5)
PATCH 1/1 bluetooth: debugfs changes use too much stack
The original code would break with a 4K stack.
---
This was compile tested only. Sorry about that.
net/bluetooth/hci_sysfs.c +7 -2
@@ -417,9 +417,11 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,struct hci_dev *hdev = file->private_data;struct inquiry_cache *cache = &hdev->inq_cache;struct inquiry_entry *e; -char buf[4096 ]; +char *buf;int n =0 ; +ssize_t ret; + buf =kmalloc (4096 ,GFP_KERNEL );hci_dev_lock_bh (hdev);for (e = cache->list; e; e = e->next) {
@@ -437,7 +439,10 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,hci_dev_unlock_bh (hdev); -return simple_read_from_buffer (userbuf, count, ppos, buf, n); + ret =simple_read_from_buffer (userbuf, count, ppos, buf, n); +kfree (buf); + +return ret; }static const struct file_operations inquiry_cache_fops = {
Dan Carpenter wrote:
Error handling?
Quoted 11 lines
The original code would break with a 4K stack.
Signed-off-by Dan Carpenter <[email protected]>---
This was compile tested only. Sorry about that.net/bluetooth/hci_sysfs.c +0
-0
net/bluetooth/hci_sysfs.c static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, · line 424
Quoted 9 lines
net/bluetooth/hci_sysfs.c +3
-1@@ -417,9 +417,11 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,struct hci_dev *hdev = file->private_data;struct inquiry_cache *cache = &hdev->inq_cache;struct inquiry_entry *e; -char buf[4096 ]; +char *buf;int n =0 ; +ssize_t ret; + buf =kmalloc (4096 ,GFP_KERNEL );
Could this kmalloc not fail?
Quoted 23 lines · Jan Ceuleers
Dan Carpenter wrote:
Error handling?
Quoted 19 lines
The original code would break with a 4K stack.
Signed-off-by Dan Carpenter <[email protected]>---
This was compile tested only. Sorry about that.net/bluetooth/hci_sysfs.c +2
-1@@ -417,9 +417,11 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,struct hci_dev *hdev = file->private_data;struct inquiry_cache *cache = &hdev->inq_cache;struct inquiry_entry *e; -char buf[4096 ]; +char *buf;int n =0 ; +ssize_t ret;
Quoted 3 lines
net/bluetooth/hci_sysfs.c static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, · line 424
Quoted 1 line
net/bluetooth/hci_sysfs.c +1
-0+ buf =kmalloc (4096 ,GFP_KERNEL );Could this kmalloc not fail?
Grr... I'm really sorry about that.
I will send an updated patch tomorrow.
regards,
dan carpenter
Marcel Holtmann
maintainerHi Dan,
Quoted 21 lines
Quoted 21 lines
Error handling?
Quoted 19 lines
The original code would break with a 4K stack.
Signed-off-by Dan Carpenter <[email protected]>---
This was compile tested only. Sorry about that.net/bluetooth/hci_sysfs.c +2
-1@@ -417,9 +417,11 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,struct hci_dev *hdev = file->private_data;struct inquiry_cache *cache = &hdev->inq_cache;struct inquiry_entry *e; -char buf[4096 ]; +char *buf;int n =0 ; +ssize_t ret;
Quoted 7 lines
Quoted 3 lines
net/bluetooth/hci_sysfs.c static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, · line 424
Quoted 1 line
net/bluetooth/hci_sysfs.c +1
-0+ buf =kmalloc (4096 ,GFP_KERNEL );Could this kmalloc not fail?
Grr... I'm really sorry about that.
I will send an updated patch tomorrow.
please don't since we fixed this already in the net-2.6 tree.
Regards
Marcel