This patch fixes error handling on function parameters.

Signed-off-by: Christian Gromm <christian.gr...@microchip.com>
---
 drivers/staging/most/usb/usb.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index e8c5a8c..e5276524 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -229,14 +229,14 @@ static unsigned int get_stream_frame_size(struct 
most_channel_config *cfg)
  */
 static int hdm_poison_channel(struct most_interface *iface, int channel)
 {
-       struct most_dev *mdev = to_mdev(iface);
+       struct most_dev *mdev;
        unsigned long flags;
        spinlock_t *lock; /* temp. lock */
 
        if (unlikely(!iface)) {
-               dev_warn(&mdev->usb_device->dev, "Poison: Bad interface.\n");
-               return -EIO;
+               return -EFAULT;
        }
+       mdev = to_mdev(iface);
        if (unlikely(channel < 0 || channel >= iface->num_channels)) {
                dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
                return -ECHRNG;
@@ -278,13 +278,13 @@ static int hdm_add_padding(struct most_dev *mdev, int 
channel, struct mbo *mbo)
        unsigned int j, num_frames;
 
        if (!frame_size)
-               return -EIO;
+               return -EFAULT;
        num_frames = mbo->buffer_length / frame_size;
 
        if (num_frames < 1) {
                dev_err(&mdev->usb_device->dev,
                        "Missed minimal transfer unit.\n");
-               return -EIO;
+               return -EINVAL;
        }
 
        for (j = num_frames - 1; j > 0; j--)
@@ -312,7 +312,7 @@ static int hdm_remove_padding(struct most_dev *mdev, int 
channel,
        unsigned int j, num_frames;
 
        if (!frame_size)
-               return -EIO;
+               return -EFAULT;
        num_frames = mbo->processed_length / USB_MTU;
 
        for (j = 1; j < num_frames; j++)
@@ -560,7 +560,7 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
        void *virt_address;
 
        if (unlikely(!iface || !mbo))
-               return -EIO;
+               return -EFAULT;
        if (unlikely(iface->num_channels <= channel || channel < 0))
                return -ECHRNG;
 
@@ -666,18 +666,18 @@ static int hdm_configure_channel(struct most_interface 
*iface, int channel,
 {
        unsigned int num_frames;
        unsigned int frame_size;
-       struct most_dev *mdev = to_mdev(iface);
-       struct device *dev = &mdev->usb_device->dev;
+       struct most_dev *mdev;
+       struct device *dev;
 
+       if (unlikely(!iface || !conf))
+               return -EFAULT;
+       mdev = to_mdev(iface);
+       dev = &mdev->usb_device->dev;
        mdev->is_channel_healthy[channel] = true;
        mdev->clear_work[channel].channel = channel;
        mdev->clear_work[channel].mdev = mdev;
        INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
 
-       if (unlikely(!iface || !conf)) {
-               dev_err(dev, "Bad interface or config pointer.\n");
-               return -EINVAL;
-       }
        if (unlikely(channel < 0 || channel >= iface->num_channels)) {
                dev_err(dev, "Channel ID out of range.\n");
                return -EINVAL;
@@ -747,11 +747,12 @@ static void hdm_request_netinfo(struct most_interface 
*iface, int channel,
 {
        struct most_dev *mdev;
 
-       BUG_ON(!iface);
+       if (!iface || !on_netinfo) {
+               WARN_ON(1);
+               return;
+       }
        mdev = to_mdev(iface);
        mdev->on_netinfo = on_netinfo;
-       if (!on_netinfo)
-               return;
 
        mdev->link_stat_timer.expires = jiffies + HZ;
        mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires);
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to