* [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
@ 2011-11-09 21:09 Peter Maydell
2011-11-14 3:00 ` andrzej zaborowski
2011-12-12 18:28 ` Anthony Liguori
0 siblings, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2011-11-09 21:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, patches
"!X == 2" is always false (spotted by Coverity), so the checks
for whether rndis is in the correct state would never fire.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
NB that although I tested that this doesn't break non-rndis
usb-net, I don't have a test image that uses rndis usb-net,
so treat this patch with the appropriate degree of caution.
(Probably safer not putting it into 1.0 unless tested.)
hw/usb-net.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/usb-net.c b/hw/usb-net.c
index a8b7c8d..f91fa32 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1268,8 +1268,9 @@ static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t si
if (is_rndis(s)) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
- if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
+ if (s->rndis_state != RNDIS_DATA_INITIALIZED) {
return -1;
+ }
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return -1;
@@ -1302,7 +1303,7 @@ static int usbnet_can_receive(VLANClientState *nc)
{
USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
- if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) {
+ if (is_rndis(s) && s->rndis_state != RNDIS_DATA_INITIALIZED) {
return 1;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
2011-11-09 21:09 [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state Peter Maydell
@ 2011-11-14 3:00 ` andrzej zaborowski
2011-11-14 8:08 ` Peter Maydell
2011-12-12 18:28 ` Anthony Liguori
1 sibling, 1 reply; 6+ messages in thread
From: andrzej zaborowski @ 2011-11-14 3:00 UTC (permalink / raw)
To: Peter Maydell; +Cc: patches, qemu-devel, Gerd Hoffmann
On 9 November 2011 22:09, Peter Maydell <peter.maydell@linaro.org> wrote:
> "!X == 2" is always false (spotted by Coverity), so the checks
> for whether rndis is in the correct state would never fire.
I pushed this patch because it's a bugfix and the check is guarded by
is_rndis() so there should be no risk of affecting non-rndis.
Cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
2011-11-14 3:00 ` andrzej zaborowski
@ 2011-11-14 8:08 ` Peter Maydell
2011-11-14 17:21 ` andrzej zaborowski
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2011-11-14 8:08 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: patches, qemu-devel, Gerd Hoffmann
On 14 November 2011 03:00, andrzej zaborowski <balrogg@gmail.com> wrote:
> On 9 November 2011 22:09, Peter Maydell <peter.maydell@linaro.org> wrote:
>> "!X == 2" is always false (spotted by Coverity), so the checks
>> for whether rndis is in the correct state would never fire.
>
> I pushed this patch because it's a bugfix and the check is guarded by
> is_rndis() so there should be no risk of affecting non-rndis.
I'm happy that non-rndis works, I tested that. What I don't know
is whether the patch breaks rndis -- it's possible the checks
were wrong all along but we never noticed because of this bug.
That's why I suggested that somebody should test the rndis case
before applying...
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
2011-11-14 8:08 ` Peter Maydell
@ 2011-11-14 17:21 ` andrzej zaborowski
2011-12-12 10:17 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: andrzej zaborowski @ 2011-11-14 17:21 UTC (permalink / raw)
To: Peter Maydell; +Cc: patches, qemu-devel, Gerd Hoffmann
On 14 November 2011 09:08, Peter Maydell <peter.maydell@linaro.org> wrote:
> I'm happy that non-rndis works, I tested that. What I don't know
> is whether the patch breaks rndis
Sorry, I misread what you said assuming that you tested a branch
affected by this patch. I'm unable to find a guest to test the rndis
mode so I reverted the patch until after release. Applying is
probably the best way to get someone to test a change like this.
Cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
2011-11-14 17:21 ` andrzej zaborowski
@ 2011-12-12 10:17 ` Peter Maydell
0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2011-12-12 10:17 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: patches, qemu-devel, Gerd Hoffmann
On 14 November 2011 17:21, andrzej zaborowski <balrogg@gmail.com> wrote:
> On 14 November 2011 09:08, Peter Maydell <peter.maydell@linaro.org> wrote:
>> I'm happy that non-rndis works, I tested that. What I don't know
>> is whether the patch breaks rndis
>
> Sorry, I misread what you said assuming that you tested a branch
> affected by this patch. I'm unable to find a guest to test the rndis
> mode so I reverted the patch until after release. Applying is
> probably the best way to get someone to test a change like this.
Well, we're past release now, I think we could reasonably (re)apply
this patch now?
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state
2011-11-09 21:09 [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state Peter Maydell
2011-11-14 3:00 ` andrzej zaborowski
@ 2011-12-12 18:28 ` Anthony Liguori
1 sibling, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2011-12-12 18:28 UTC (permalink / raw)
To: Peter Maydell; +Cc: patches, qemu-devel, Gerd Hoffmann
On 11/09/2011 03:09 PM, Peter Maydell wrote:
> "!X == 2" is always false (spotted by Coverity), so the checks
> for whether rndis is in the correct state would never fire.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> NB that although I tested that this doesn't break non-rndis
> usb-net, I don't have a test image that uses rndis usb-net,
> so treat this patch with the appropriate degree of caution.
> (Probably safer not putting it into 1.0 unless tested.)
>
> hw/usb-net.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/usb-net.c b/hw/usb-net.c
> index a8b7c8d..f91fa32 100644
> --- a/hw/usb-net.c
> +++ b/hw/usb-net.c
> @@ -1268,8 +1268,9 @@ static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t si
>
> if (is_rndis(s)) {
> msg = (struct rndis_packet_msg_type *) s->in_buf;
> - if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
> + if (s->rndis_state != RNDIS_DATA_INITIALIZED) {
> return -1;
> + }
> if (size + sizeof(struct rndis_packet_msg_type)> sizeof(s->in_buf))
> return -1;
>
> @@ -1302,7 +1303,7 @@ static int usbnet_can_receive(VLANClientState *nc)
> {
> USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
>
> - if (is_rndis(s)&& !s->rndis_state == RNDIS_DATA_INITIALIZED) {
> + if (is_rndis(s)&& s->rndis_state != RNDIS_DATA_INITIALIZED) {
> return 1;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-12-12 18:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09 21:09 [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state Peter Maydell
2011-11-14 3:00 ` andrzej zaborowski
2011-11-14 8:08 ` Peter Maydell
2011-11-14 17:21 ` andrzej zaborowski
2011-12-12 10:17 ` Peter Maydell
2011-12-12 18:28 ` Anthony Liguori
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).