Patchwork Fix dediprog crash if usb_open() fails

login
register
about
Submitter David Woodhouse
Date 2013-07-29 13:40:14
Message ID <1375105214.5378.25.camel@i7.infradead.org>
Download mbox | patch
Permalink /patch/3996/
State Accepted
Headers show

Comments

David Woodhouse - 2013-07-29 13:40:14
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

---
Ick. You made me touch Subversion, even if only through 'git svn clone'.
Stefan Tauner - 2013-07-30 09:37:50
On Mon, 29 Jul 2013 14:40:14 +0100
David Woodhouse <dwmw2@infradead.org> wrote:

> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> 
> ---
> Ick. You made me touch Subversion, even if only through 'git svn clone'.

Just to remind you how good we have it today ;)

> diff --git a/dediprog.c b/dediprog.c
> index fb95d10..2640808 100644
> --- a/dediprog.c
> +++ b/dediprog.c
> @@ -884,6 +884,10 @@ int dediprog_init(void)
>  	msg_pdbg("Found USB device (%04x:%04x).\n",
>  		 dev->descriptor.idVendor, dev->descriptor.idProduct);
>  	dediprog_handle = usb_open(dev);
> +	if (!dediprog_handle) {
> +		msg_perr("Could not open USB device: %s\n", usb_strerror());
> +		return 1;
> +	}
>  	ret = usb_set_configuration(dediprog_handle, 1);
>  	if (ret < 0) {
>  		msg_perr("Could not set USB device configuration: %i %s\n",
> 

Excellent, thank you!
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
and committed in r1705.

Patch

diff --git a/dediprog.c b/dediprog.c
index fb95d10..2640808 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -884,6 +884,10 @@  int dediprog_init(void)
 	msg_pdbg("Found USB device (%04x:%04x).\n",
 		 dev->descriptor.idVendor, dev->descriptor.idProduct);
 	dediprog_handle = usb_open(dev);
+	if (!dediprog_handle) {
+		msg_perr("Could not open USB device: %s\n", usb_strerror());
+		return 1;
+	}
 	ret = usb_set_configuration(dediprog_handle, 1);
 	if (ret < 0) {
 		msg_perr("Could not set USB device configuration: %i %s\n",