diff options
author | Kurt Kanzenbach <ly80toro@cip.cs.fau.de> | 2013-04-04 16:03:08 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-05 14:22:50 -0700 |
commit | 31398f6307d52fcb5aca6481fa4c84100aea97e3 (patch) | |
tree | 886addb01af238a05a3e8e38dae515c7e1f687b5 /drivers/staging/usbip | |
parent | ca9fb17e9377f820ac64e897452aaca0a079d766 (diff) | |
download | op-kernel-dev-31398f6307d52fcb5aca6481fa4c84100aea97e3.zip op-kernel-dev-31398f6307d52fcb5aca6481fa4c84100aea97e3.tar.gz |
staging: usbip: simplified errorhandling
In each errorcase spin_unlock_irq is called and -EINVAL is returned.
To simplify that I created a label called "err" doing that.
On Success count will be returned.
Signed-off-by: Kurt Kanzenbach <ly80toro@cip.cs.fau.de>
Signed-off-by: Stefan Reif <ke42caxa@cip.cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/usbip')
-rw-r--r-- | drivers/staging/usbip/stub_dev.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 471cd2a..c75ae63 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -86,6 +86,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, struct stub_device *sdev = dev_get_drvdata(dev); int sockfd = 0; struct socket *socket; + ssize_t err = -EINVAL; if (!sdev) { dev_err(dev, "sdev is null\n"); @@ -101,15 +102,13 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, if (sdev->ud.status != SDEV_ST_AVAILABLE) { dev_err(dev, "not ready\n"); - spin_unlock_irq(&sdev->ud.lock); - return -EINVAL; + goto err; } socket = sockfd_to_socket(sockfd); - if (!socket) { - spin_unlock_irq(&sdev->ud.lock); - return -EINVAL; - } + if (!socket) + goto err; + sdev->ud.tcp_socket = socket; spin_unlock_irq(&sdev->ud.lock); @@ -127,16 +126,19 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, dev_info(dev, "stub down\n"); spin_lock_irq(&sdev->ud.lock); - if (sdev->ud.status != SDEV_ST_USED) { - spin_unlock_irq(&sdev->ud.lock); - return -EINVAL; - } + if (sdev->ud.status != SDEV_ST_USED) + goto err; + spin_unlock_irq(&sdev->ud.lock); usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); } return count; + +err: + spin_unlock_irq(&sdev->ud.lock); + return err; } static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd); |