linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: vhci: Ignore return code of nonseekable_open()
@ 2012-03-28  9:48 David Herrmann
  2012-03-28 10:25 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: David Herrmann @ 2012-03-28  9:48 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, padovan, johan.hedberg, David Herrmann

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.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
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(-)

diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 2ed6ab1..d8a2a4f 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -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)
-- 
1.7.9.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: vhci: Ignore return code of nonseekable_open()
  2012-03-28  9:48 [PATCH] Bluetooth: vhci: Ignore return code of nonseekable_open() David Herrmann
@ 2012-03-28 10:25 ` Marcel Holtmann
  2012-03-28 10:42   ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2012-03-28 10:25 UTC (permalink / raw)
  To: David Herrmann; +Cc: linux-bluetooth, padovan, johan.hedberg

Hi David,

> 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.
> 
> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
> ---
> 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(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: vhci: Ignore return code of nonseekable_open()
  2012-03-28 10:25 ` Marcel Holtmann
@ 2012-03-28 10:42   ` Johan Hedberg
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2012-03-28 10:42 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: David Herrmann, linux-bluetooth, padovan

Hi,

On Wed, Mar 28, 2012, Marcel Holtmann wrote:
> > 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.
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
> > ---
> > 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(-)
> 
> Acked-by: Marcel Holtmann <marcel@holtmann.org>

Applied to bluetooth-next. Thanks.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-28 10:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-28  9:48 [PATCH] Bluetooth: vhci: Ignore return code of nonseekable_open() David Herrmann
2012-03-28 10:25 ` Marcel Holtmann
2012-03-28 10:42   ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).