From: David Miller <davem@davemloft.net>
To: marcel@holtmann.org
Cc: netdev@vger.kernel.org
Subject: Re: Bluetooth fixes for 2.6.20-rc4
Date: Sun, 07 Jan 2007 17:11:23 -0800 (PST) [thread overview]
Message-ID: <20070107.171123.43392648.davem@davemloft.net> (raw)
In-Reply-To: <1168216304.12025.10.camel@violet>
From: Marcel Holtmann <marcel@holtmann.org>
Date: Mon, 08 Jan 2007 01:31:44 +0100
> Commit: 2b2e64be763c5e64d4ae4a061825b18decf1edf7
> Author: Marcel Holtmann <marcel@holtmann.org> Mon, 08 Jan 2007 01:00:33 +0100
>
> [Bluetooth] Fix uninitialized return value for RFCOMM sendmsg()
>
> When calling send() with a zero length parameter on a RFCOMM socket
> it returns a positive value. In this rare case the variable err is
> used uninitialized and unfortunately its value is returned.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
You can't fix this bug like that.
If sendmsg() sends any bytes, it should return the number of
bytes sent even if an error occurs mid-stream.
With this change, you'll now return the error instead of
the number of bytes sent. That's what the new "sent = err"
assignment does.
You have to do sendmsg() with those semantics, or else you lose
information in that the user can never know how many bytes were
actually sent successfully. Losing the error after successfully sent
bytes is OK, if the error persists the user will get it when it
recalls sendmsg() to push the rest of the remaining bytes out.
The original code tried to do it right.
If the bug is that 'err' is uninitialized, why try to fix this
by being fancy, just initialize it :-)
next prev parent reply other threads:[~2007-01-08 1:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-08 0:31 Bluetooth fixes for 2.6.20-rc4 Marcel Holtmann
2007-01-08 1:11 ` David Miller [this message]
2007-01-08 1:19 ` Marcel Holtmann
2007-01-08 1:24 ` David Miller
2007-01-08 1:44 ` Marcel Holtmann
2007-01-08 3:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070107.171123.43392648.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).