* [PATCH 1/1] usb: return correct errno on failures
@ 2016-11-29 12:55 Pan Bian
0 siblings, 0 replies; only message in thread
From: Pan Bian @ 2016-11-29 12:55 UTC (permalink / raw)
To: linux-usb; +Cc: linux-kernel, Pan Bian
In function __wa_xfer_setup_segs(), variable result takes the return
value. Its value should be a negative errno on failures. Because result
may be reassigned in a loop, and its value is guaranteed to be not less
than 0 during the following repeats of the loop. So when the call to
kmalloc() or usb_alloc_urb() fails in the loop, the value of variable
result may be 0 (indicates no error), which is inconsistent with the
execution status. This patch fixes the bug, initializing variable result
with -ENOMEM in the loop.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/usb/wusbcore/wa-xfer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 167fcc71..e70322b 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -1203,6 +1203,7 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size)
sizeof(struct wa_xfer_packet_info_hwaiso) +
(seg_isoc_frame_count * sizeof(__le16));
}
+ result = -ENOMEM;
seg = xfer->seg[cnt] = kmalloc(alloc_size + iso_pkt_descr_size,
GFP_ATOMIC);
if (seg == NULL)
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-11-29 12:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 12:55 [PATCH 1/1] usb: return correct errno on failures Pan Bian
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).