Bluetooth: vhci: Ignore return code of nonseekable_open()
PATCH 1/1 Bluetooth: vhci: Ignore return code of nonseekable_open()
The comment in ./fs/open.c clearly states that nonseekable_open() will never fail. Therefore, we can safely ignore the return code. This is the recommended way to deal with nonseekable_open().
Our current code looks like nonseekable_open() is checked for the return code. However, if we check the return code, we must also kfree() our private data if the open fails. To avoid this overhead and to avoid confusion, we simply drop the return code and return 0.
---
See the UHID discussion for more information. Marcel suggested to also fix vhci so here is the patch ;)
drivers/bluetooth/hci_vhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_vhci.c +2 -1
@@ -260,8 +260,9 @@ static int vhci_open(struct inode *inode, struct file *file) } file->private_data = data; +nonseekable_open (inode, file); -return nonseekable_open (inode, file); +return 0 ; }static int vhci_release (struct inode *inode,struct file *file)
Signature · 1 line
1.7.9.4
Hi David,
Quoted 8 lines
The comment in
./fs/open.cclearly states thatnonseekable_open()will never fail. Therefore, we can safely ignore the return code. This is the recommended way to deal withnonseekable_open().
Our current code looks likenonseekable_open()is checked for the return code. However, if we check the return code, we must alsokfree()our private data if the open fails. To avoid this overhead and to avoid confusion, we simply drop the return code and return 0.
Quoted 7 lines
Signed-off-by David Herrmann <[email protected]>---
See the UHID discussion for more information. Marcel suggested to also fix vhci so here is the patch ;)drivers/bluetooth/hci_vhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Regards
Marcel
Johan Hedberg
AppliedHi,
Quoted 13 lines · Marcel Holtmann
Quoted 13 lines
The comment in
./fs/open.cclearly states thatnonseekable_open()will never fail. Therefore, we can safely ignore the return code. This is the recommended way to deal withnonseekable_open().
Our current code looks likenonseekable_open()is checked for the return code. However, if we check the return code, we must alsokfree()our private data if the open fails. To avoid this overhead and to avoid confusion, we simply drop the return code and return 0.Signed-off-by David Herrmann <[email protected]>---
See the UHID discussion for more information. Marcel suggested to also fix vhci so here is the patch ;)
Quoted 4 lines
Quoted 2 lines
drivers/bluetooth/hci_vhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Acked-by Marcel Holtmann <[email protected]>
Applied to bluetooth-next. Thanks.
Johan