diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2010-04-08 20:40:47 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2010-04-08 20:40:47 -0400 |
commit | 67f6d3710079a6bfc1f3975add70be9e445484d9 (patch) | |
tree | 889f57597acd61b9117c6e8bc92bcecc00aa154b | |
parent | a7eb8fcf812c69c32d430b6fc79806256921f75e (diff) | |
download | seabios-67f6d3710079a6bfc1f3975add70be9e445484d9.tar.gz |
Fix possible unitialized variable issue in usb msc.
On an error path, desc and udrive_g may not be initialized.
-rw-r--r-- | src/usb-msc.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/usb-msc.c b/src/usb-msc.c index a7047fd2..e91d9161 100644 --- a/src/usb-msc.c +++ b/src/usb-msc.c @@ -187,18 +187,6 @@ usb_msc_init(struct usb_pipe *pipe return -1; } - // Find bulk in and bulk out endpoints. - struct usb_endpoint_descriptor *indesc = findEndPointDesc( - iface, imax, USB_ENDPOINT_XFER_BULK, USB_DIR_IN); - struct usb_endpoint_descriptor *outdesc = findEndPointDesc( - iface, imax, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT); - if (!indesc || !outdesc) - goto fail; - struct usb_pipe *bulkin = alloc_bulk_pipe(pipe, indesc); - struct usb_pipe *bulkout = alloc_bulk_pipe(pipe, outdesc); - if (!bulkin || !bulkout) - goto fail; - // Allocate drive structure. char *desc = malloc_tmphigh(MAXDESCSIZE); struct usbdrive_s *udrive_g = malloc_fseg(sizeof(*udrive_g)); @@ -208,8 +196,18 @@ usb_msc_init(struct usb_pipe *pipe } memset(udrive_g, 0, sizeof(*udrive_g)); udrive_g->drive.type = DTYPE_USB; - udrive_g->bulkin = bulkin; - udrive_g->bulkout = bulkout; + + // Find bulk in and bulk out endpoints. + struct usb_endpoint_descriptor *indesc = findEndPointDesc( + iface, imax, USB_ENDPOINT_XFER_BULK, USB_DIR_IN); + struct usb_endpoint_descriptor *outdesc = findEndPointDesc( + iface, imax, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT); + if (!indesc || !outdesc) + goto fail; + udrive_g->bulkin = alloc_bulk_pipe(pipe, indesc); + udrive_g->bulkout = alloc_bulk_pipe(pipe, outdesc); + if (!udrive_g->bulkin || !udrive_g->bulkout) + goto fail; // Validate drive and find block size and sector count. struct disk_op_s dop; |