From: Kevin O'Connor Date: Fri, 9 Apr 2010 00:40:47 +0000 (-0400) Subject: Fix possible unitialized variable issue in usb msc. X-Git-Tag: rel-0.6.1~89 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=67f6d3710079a6bfc1f3975add70be9e445484d9;p=seabios.git Fix possible unitialized variable issue in usb msc. On an error path, desc and udrive_g may not be initialized. --- diff --git a/src/usb-msc.c b/src/usb-msc.c index a7047fd..e91d916 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;