usb: dwc2: fix sparse warning
authorPaul Zimmerman <Paul.Zimmerman@synopsys.com>
Fri, 25 Apr 2014 21:18:13 +0000 (14:18 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2014 21:56:16 +0000 (14:56 -0700)
Sparse warns about the __le16 wValue from the USB SetAddress
command being used without converting it to CPU endianness. Fix
that, and also add a bit of defensive masking of the received
wValue before using it.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc2/gadget.c

index dc0faee031fb8a0200b0d41acc40958047ef922e..2057c380969ed99a87158a27dd376d7bce3b8fea 100644 (file)
@@ -1094,7 +1094,8 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
                        s3c_hsotg_disconnect(hsotg);
                        dcfg = readl(hsotg->regs + DCFG);
                        dcfg &= ~DCFG_DEVADDR_MASK;
-                       dcfg |= ctrl->wValue << DCFG_DEVADDR_SHIFT;
+                       dcfg |= (le16_to_cpu(ctrl->wValue) <<
+                                DCFG_DEVADDR_SHIFT) & DCFG_DEVADDR_MASK;
                        writel(dcfg, hsotg->regs + DCFG);
 
                        dev_info(hsotg->dev, "new address %d\n", ctrl->wValue);