[PATCH] usb: usbtmc: check size before allocating buffer and remove duplicated allocation

2018-09-27 Thread Colin King
From: Colin Ian King 

Currently the allocation of a buffer is performed before a sanity check on
the required buffer size and if the buffer size is too large the error exit
return leaks the allocated buffer.  Fix this by checking the size before
allocating.

Also, the same buffer is allocated again inside an if statement, causing
the first allocation to be leaked.  Fix this by removing this second
redundant allocation.

Detected by CoverityScan, CID#1473697 ("Resource leak")

Fixes: 658f24f4523e ("usb: usbtmc: Add ioctl for generic requests on control")
Signed-off-by: Colin Ian King 
---
 drivers/usb/class/usbtmc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 0fcb81a1399b..c01edff190d2 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1895,18 +1895,14 @@ static int usbtmc_ioctl_request(struct 
usbtmc_device_data *data,
if (res)
return -EFAULT;
 
+   if (request.req.wLength > USBTMC_BUFSIZE)
+   return -EMSGSIZE;
+
buffer = kmalloc(request.req.wLength, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
 
-   if (request.req.wLength > USBTMC_BUFSIZE)
-   return -EMSGSIZE;
-
if (request.req.wLength) {
-   buffer = kmalloc(request.req.wLength, GFP_KERNEL);
-   if (!buffer)
-   return -ENOMEM;
-
if ((request.req.bRequestType & USB_DIR_IN) == 0) {
/* Send control data to device */
res = copy_from_user(buffer, request.data,
-- 
2.17.1



[PATCH] usb: gadget: tcm: fix spelling mistake: "Manufactor" -> "Manufacturer"

2018-05-22 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in usbg_us_strings array

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/legacy/tcm_usb_gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c 
b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 682bf99dcf76..40870227999a 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -41,7 +41,7 @@ static struct usb_device_descriptor usbg_device_desc = {
 #define USB_G_STR_CONFIG USB_GADGET_FIRST_AVAIL_IDX
 
 static struct usb_string   usbg_us_strings[] = {
-   [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufactor",
+   [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufacturer",
[USB_GADGET_PRODUCT_IDX].s  = "Target Product",
[USB_GADGET_SERIAL_IDX].s   = "0001",
[USB_G_STR_CONFIG].s= "default config",
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb-misc: sisusbvga: fix spelling mistake: "asymmeric" -> "asymmetric"

2018-04-27 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in text string

Signed-off-by: Colin Ian King 
---
 drivers/usb/misc/sisusbvga/sisusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c 
b/drivers/usb/misc/sisusbvga/sisusb.c
index 3e65bdc2615c..f92c5df26320 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2107,7 +2107,7 @@ static void sisusb_get_ramconfig(struct sisusb_usb_data 
*sisusb)
bw = busSDR[(tmp8 & 0x03)];
break;
case 2:
-   ramtypetext1 = "asymmeric";
+   ramtypetext1 = "asymmetric";
sisusb->vramsize += sisusb->vramsize/2;
bw = busDDRA[(tmp8 & 0x03)];
break;
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][usb-next] usb: dwc2: ix spelling mistake: "genereted" -> "generated"

2018-03-13 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in dev_warn warning message text.

Signed-off-by: Colin Ian King 
---
 drivers/usb/dwc2/hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index dcfda5eb4cac..190f95964000 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5433,7 +5433,7 @@ int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
 
/* Wait for the HPRT0.PrtSusp register field to be set */
if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 300))
-   dev_warn(hsotg->dev, "Suspend wasn't genereted\n");
+   dev_warn(hsotg->dev, "Suspend wasn't generated\n");
 
/*
 * We need to disable interrupts to prevent servicing of any IRQ
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net/usb/kalmia: use ARRAY_SIZE for various array sizing calculations

2018-03-02 Thread Colin King
From: Colin Ian King 

Use the ARRAY_SIZE macro on a couple of arrays to determine
size of the arrays. Also fix up alignment to clean up a checkpatch
warning. Improvement suggested by Coccinelle.

Signed-off-by: Colin Ian King 
---
 drivers/net/usb/kalmia.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index ce0b0b4e3a57..2243da0aa991 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c
@@ -114,14 +114,14 @@ kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 
*ethernet_addr)
return -ENOMEM;
 
memcpy(usb_buf, init_msg_1, 12);
-   status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1)
-   / sizeof(init_msg_1[0]), usb_buf, 24);
+   status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_1),
+usb_buf, 24);
if (status != 0)
return status;
 
memcpy(usb_buf, init_msg_2, 12);
-   status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2)
-   / sizeof(init_msg_2[0]), usb_buf, 28);
+   status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_2),
+usb_buf, 28);
if (status != 0)
return status;
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usbip: vudc: fix null pointer dereference on udc->lock

2018-02-22 Thread Colin King
From: Colin Ian King 

Currently the driver attempts to spin lock on udc->lock before a NULL
pointer check is performed on udc, hence there is a potential null
pointer dereference on udc->lock.  Fix this by moving the null check
on udc before the lock occurs.

Fixes: ea6873a45a22 ("usbip: vudc: Add SysFS infrastructure for VUDC")
Signed-off-by: Colin Ian King 
---
 drivers/usb/usbip/vudc_sysfs.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index d86f7291..6dcd3ff655c3 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, 
struct device_attribute *a
if (rv != 0)
return -EINVAL;
 
+   if (!udc) {
+   dev_err(dev, "no device");
+   return -ENODEV;
+   }
spin_lock_irqsave(>lock, flags);
/* Don't export what we don't have */
-   if (!udc || !udc->driver || !udc->pullup) {
-   dev_err(dev, "no device or gadget not bound");
+   if (!udc->driver || !udc->pullup) {
+   dev_err(dev, "gadget not bound");
ret = -ENODEV;
goto unlock;
}
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: gadget: function: remove redundant initialization of 'tv_nexus'

2018-01-26 Thread Colin King
From: Colin Ian King 

Pointer tv_nexus is being initialized a value and this is never read
and is later being updated with the same value. Remove the redundant
initialization so that the assignment to tv_nexus is performed later
and more local to when it is being read.

Cleans up clang warning:
drivers/usb/gadget/function/f_tcm.c:1097:25: warning: Value stored to
'tv_nexus' during its initialization is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/function/f_tcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c 
b/drivers/usb/gadget/function/f_tcm.c
index da81cf16b850..d78dbb73bde8 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1094,7 +1094,7 @@ static int usbg_submit_command(struct f_uas *fu,
struct command_iu *cmd_iu = cmdbuf;
struct usbg_cmd *cmd;
struct usbg_tpg *tpg = fu->tpg;
-   struct tcm_usbg_nexus *tv_nexus = tpg->tpg_nexus;
+   struct tcm_usbg_nexus *tv_nexus;
u32 cmd_len;
u16 scsi_tag;
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: wusbcore: remove redundant re-assignment to pointer 'dev'

2018-01-26 Thread Colin King
From: Colin Ian King 

Pointer dev is initialized and then re-assigned with the same value
a little later, hence the second assignment is redundant and can be
removed.

Cleans up clang warning:
drivers/usb/wusbcore/wa-nep.c:88:17: warning: Value stored to 'dev'
during its initialization is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/wusbcore/wa-nep.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/wusbcore/wa-nep.c b/drivers/usb/wusbcore/wa-nep.c
index 9fdcb6b84abf..5f0656db5482 100644
--- a/drivers/usb/wusbcore/wa-nep.c
+++ b/drivers/usb/wusbcore/wa-nep.c
@@ -93,7 +93,6 @@ static void wa_notif_dispatch(struct work_struct *ws)
goto out;   /* screw it */
 #endif
atomic_dec(>notifs_queued); /* Throttling ctl */
-   dev = >usb_iface->dev;
size = nw->size;
itr = nw->data;
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: serial: remove redundant initializations of 'mos_parport'

2018-01-17 Thread Colin King
From: Colin Ian King 

The pointer mos_parport is being initialized to pp->private_data and
then the assignment is duplicated after a spin lock.  Remove the
initialization as it occurs before the spin lock and it is a redundant
assignment.

Cleans up clang warnings:
drivers/usb/serial/mos7720.c:521:26: warning: Value stored to
'mos_parport' during its initialization is never read
drivers/usb/serial/mos7720.c:557:26: warning: Value stored to
'mos_parport' during its initialization is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/serial/mos7720.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index f4df3d5bf69c..bd57630e67e2 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -518,7 +518,7 @@ static void parport_mos7715_write_control(struct parport 
*pp, unsigned char d)
 
 static unsigned char parport_mos7715_read_control(struct parport *pp)
 {
-   struct mos7715_parport *mos_parport = pp->private_data;
+   struct mos7715_parport *mos_parport;
__u8 dcr;
 
spin_lock(_lock);
@@ -554,7 +554,7 @@ static unsigned char parport_mos7715_frob_control(struct 
parport *pp,
 static unsigned char parport_mos7715_read_status(struct parport *pp)
 {
unsigned char status;
-   struct mos7715_parport *mos_parport = pp->private_data;
+   struct mos7715_parport *mos_parport;
 
spin_lock(_lock);
mos_parport = pp->private_data;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][next] usbip: vhci: fix spelling mistake: "synchronuously" -> "synchronously"

2018-01-03 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in dev_dbg debug message.

Signed-off-by: Colin Ian King 
---
 drivers/usb/usbip/vhci_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 112ebb90d8c9..44cd64518925 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -30,7 +30,7 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device 
*vdev, __u32 seqnum)
/* fall through */
case -ECONNRESET:
dev_dbg(>dev->dev,
-"urb seq# %u was unlinked %ssynchronuously\n",
+"urb seq# %u was unlinked %ssynchronously\n",
 seqnum, status == -ENOENT ? "" : "a");
break;
case -EINPROGRESS:
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][usb-next] usb: xhci: make function xhci_dbc_free_req static

2017-12-11 Thread Colin King
From: Colin Ian King 

Function xhci_dbc_free_req is local to the source and does not need to
be in global scope, so make it static.

Cleans up sparse warning:
symbol 'xhci_dbc_free_req' was not declared. Should it be static?

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/xhci-dbgtty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index 48811d72a94c..8d47b6fbf973 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -122,7 +122,7 @@ static void dbc_write_complete(struct xhci_hcd *xhci, 
struct dbc_request *req)
spin_unlock(>port_lock);
 }
 
-void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req)
+static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req)
 {
kfree(req->buf);
dbc_free_request(dep, req);
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: atm: use setup_timer instead of init_timer

2017-11-24 Thread Colin King
From: Colin Ian King 

Use setup_timer function instead of initializing timer with the
function and data fields.

Signed-off-by: Colin Ian King 
---
 drivers/usb/atm/usbatm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 044264aa1f96..ef456cd0d3ab 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -998,9 +998,8 @@ static void usbatm_init_channel(struct usbatm_channel 
*channel)
 {
spin_lock_init(>lock);
INIT_LIST_HEAD(>list);
-   channel->delay.function = usbatm_tasklet_schedule;
-   channel->delay.data = (unsigned long) >tasklet;
-   init_timer(>delay);
+   setup_timer(>delay, usbatm_tasklet_schedule,
+   (unsigned long)>tasklet);
 }
 
 int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id 
*id,
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: gadget: udc: fix spelling mistake "unexpect" -> "unexpected"

2017-11-24 Thread Colin King
From: Colin Ian King 

Trival fix to spelling mistake in ERR message

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index d606d4f13098..e5b4ee96c4bf 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1543,7 +1543,7 @@ static void ep0_req_complete(struct fsl_udc *udc, struct 
fsl_ep *ep0,
udc->ep0_state = WAIT_FOR_SETUP;
break;
case WAIT_FOR_SETUP:
-   ERR("Unexpect ep0 packets\n");
+   ERR("Unexpected ep0 packets\n");
break;
default:
ep0stall(udc);
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: usbip: fix spelling mistake: "synchronuously" -> "synchronously"

2017-11-22 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in error message text

Signed-off-by: Colin Ian King 
---
 drivers/usb/usbip/vhci_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 90577e8b2282..a9813f1d507d 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -31,7 +31,7 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device 
*vdev, __u32 seqnum)
/* fall through */
case -ECONNRESET:
dev_info(>dev->dev,
-"urb %p was unlinked %ssynchronuously.\n", urb,
+"urb %p was unlinked %ssynchronously.\n", urb,
 status == -ENOENT ? "" : "a");
break;
case -EINPROGRESS:
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: gadget: legacy: remove redundant zero assignment to variable 'value'

2017-11-22 Thread Colin King
From: Colin Ian King 

The variable value is being assigned to zero but that value is never being
read.  Either value is being reassigned in the following if condition, or
it is never read and the function returns. In both cases the assignment is
redundant and can be removed. Cleans up clang warning:

drivers/usb/gadget/legacy/inode.c:1473:4: warning: Value stored to 'value'
is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/legacy/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index 9343ec436485..cb8e1761d405 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1470,7 +1470,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
dev->setup_wLength = w_length;
dev->setup_out_ready = 0;
dev->setup_out_error = 0;
-   value = 0;
 
/* read DATA stage for OUT right away */
if (unlikely (!dev->setup_in && w_length)) {
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: serial: iuu_phoenix: remove redundant assignment of DIV to itself

2017-11-20 Thread Colin King
From: Colin Ian King 

The assignment of DIV to itself is redundant and can be removed.

Signed-off-by: Colin Ian King 
---
 drivers/usb/serial/iuu_phoenix.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 397a8012ffa3..62c91e360baf 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -472,7 +472,6 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
}
}
P2 = ((P - PO) / 2) - 4;
-   DIV = DIV;
PUMP = 0x04;
PBmsb = (P2 >> 8 & 0x03);
PBlsb = P2 & 0xFF;
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: gadget: don't dereference g until after it has been null checked

2017-11-14 Thread Colin King
From: Colin Ian King 

Avoid dereferencing pointer g until after g has been sanity null checked;
move the assignment of cdev much later when it is required into a more
local scope.

Detected by CoverityScan, CID#1222135 ("Dereference before null check")

Fixes: b785ea7ce662 ("usb: gadget: composite: fix ep->maxburst initialization")
Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/composite.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index eec14e6ed20b..77c7ecca816a 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -146,7 +146,6 @@ int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
 {
-   struct usb_composite_dev*cdev = get_gadget_data(g);
struct usb_endpoint_descriptor *chosen_desc = NULL;
struct usb_descriptor_header **speed_desc = NULL;
 
@@ -226,8 +225,12 @@ int config_ep_by_speed(struct usb_gadget *g,
_ep->maxburst = comp_desc->bMaxBurst + 1;
break;
default:
-   if (comp_desc->bMaxBurst != 0)
+   if (comp_desc->bMaxBurst != 0) {
+   struct usb_composite_dev *cdev;
+
+   cdev = get_gadget_data(g);
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
+   }
_ep->maxburst = 1;
break;
}
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: host: whci: remove redundant variable t

2017-11-08 Thread Colin King
From: Colin Ian King 

Variable t is assigned but never read, it is redundant and therefore
can be removed. Cleans up clang warning:

drivers/usb/host/whci/asl.c:106:3: warning: Value stored to 't' is
never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/whci/asl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c
index c5ac9efb076a..276fb34c8efd 100644
--- a/drivers/usb/host/whci/asl.c
+++ b/drivers/usb/host/whci/asl.c
@@ -90,9 +90,7 @@ static uint32_t process_qset(struct whc *whc, struct whc_qset 
*qset)
 
while (qset->ntds) {
struct whc_qtd *td;
-   int t;
 
-   t = qset->td_start;
td = >qtd[qset->td_start];
status = le32_to_cpu(td->status);
 
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: udc-xilinx: remove redundant pointer udc

2017-11-08 Thread Colin King
From: Colin Ian King 

Pointer udc is assigned but never read, hence it is redundant and
can be removed. Cleans up clang warning:

drivers/usb/gadget/udc/udc-xilinx.c:974:2: warning: Value stored
to 'udc' is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/udc-xilinx.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c 
b/drivers/usb/gadget/udc/udc-xilinx.c
index 7da2b9ce8cb3..6407e433bc78 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -963,10 +963,8 @@ static struct usb_request *xudc_ep_alloc_request(struct 
usb_ep *_ep,
 gfp_t gfp_flags)
 {
struct xusb_ep *ep = to_xusb_ep(_ep);
-   struct xusb_udc *udc;
struct xusb_req *req;
 
-   udc = ep->udc;
req = kzalloc(sizeof(*req), gfp_flags);
if (!req)
return NULL;
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: host: fix incorrect updating of offset

2017-11-07 Thread Colin King
From: Colin Ian King 

The variable temp is incorrectly being updated, instead it should
be offset otherwise the loop just reads the same capability value
and loops forever.  Thanks to Alan Stern for pointing out the
correct fix to my original fix.  Fix also cleans up clang warning:

drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
is never read

Fixes: d49d43174400 ("USB: misc ehci updates")
Signed-off-by: Colin Ian King 
---
 drivers/usb/host/ehci-dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 7fb21d01b3d0..3bd0b2273171 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -838,7 +838,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer 
*buf)
default:/* unknown */
break;
}
-   temp = (cap >> 8) & 0xff;
+   offset = (cap >> 8) & 0xff;
}
}
 #endif
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V2] usb: gadget: pxa27x: Remove redundant assignment to is_short and dev

2017-11-07 Thread Colin King
From: Colin Ian King 

Variable is_short is set to zero but this value is never read as it is
overwritten with a new value later on, hence it is a redundant
assignment and can be removed.  Pointer dev is assigned a value that
is not read and it is updated a few statements later, this too is
redundant and can be removed. Cleans up clan warnings:

drivers/usb/gadget/udc/pxa27x_udc.c:986:3: warning: Value stored
to 'is_short' is never read
drivers/usb/gadget/udc/pxa27x_udc.c:1141:2: warning: Value stored
to 'dev' is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index 14606f340325..d88e56cce56d 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -984,8 +984,6 @@ static int write_fifo(struct pxa_ep *ep, struct 
pxa27x_request *req)
 
max = ep->fifo_size;
do {
-   is_short = 0;
-
udccsr = udc_ep_readl(ep, UDCCSR);
if (udccsr & UDCCSR_PC) {
ep_vdbg(ep, "Clearing Transmit Complete, udccsr=%x\n",
@@ -1139,7 +1137,6 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct 
usb_request *_req,
if (unlikely(!_ep))
return -EINVAL;
 
-   dev = udc_usb_ep->dev;
ep = udc_usb_ep->pxa_ep;
if (unlikely(!ep))
return -EINVAL;
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: pxa27x: Remove redundant assignment to is_short

2017-11-07 Thread Colin King
From: Colin Ian King 

Variable is set to zero but this value is never read as it is
overwritten with a new value later on, hence it is a redundant
assignment and can be removed. Cleans up clang warning:

drivers/usb/gadget/udc/pxa27x_udc.c:1141:2: warning: Value stored
to 'dev' is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index 14606f340325..e3d362cc47db 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -984,8 +984,6 @@ static int write_fifo(struct pxa_ep *ep, struct 
pxa27x_request *req)
 
max = ep->fifo_size;
do {
-   is_short = 0;
-
udccsr = udc_ep_readl(ep, UDCCSR);
if (udccsr & UDCCSR_PC) {
ep_vdbg(ep, "Clearing Transmit Complete, udccsr=%x\n",
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: host: isp1362-hcd: remove a couple of redundant assignments

2017-11-07 Thread Colin King
From: Colin Ian King 

Variable index is being initialized and the value is never read,
it is being updated a few statements later, so remove the redundant
initialization.  Variable total is being updated but the value is
never read, so this is also redundant and can be removed. Cleans
up two clang warnings:

drivers/usb/host/isp1362-hcd.c:715:6: warning: Value stored to
'index' during its initialization is never read
drivers/usb/host/isp1362-hcd.c:2254:2: warning: Value stored to
'total' is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/isp1362-hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index c7e60b662e9b..b21c386e6a46 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -713,7 +713,7 @@ static inline void enable_istl_transfers(struct isp1362_hcd 
*isp1362_hcd, int fl
 static int submit_req(struct isp1362_hcd *isp1362_hcd, struct urb *urb,
  struct isp1362_ep *ep, struct isp1362_ep_queue *epq)
 {
-   int index = epq->free_ptd;
+   int index;
 
prepare_ptd(isp1362_hcd, urb, ep, epq, 0);
index = claim_ptd_buffers(epq, ep, ep->length);
@@ -2253,7 +2253,6 @@ static int isp1362_mem_config(struct usb_hcd *hcd)
return -ENOMEM;
}
 
-   total = istl_size + intl_size + atl_size;
spin_lock_irqsave(_hcd->lock, flags);
 
for (i = 0; i < 2; i++) {
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: adutux: remove redundant variable minor

2017-11-07 Thread Colin King
From: Colin Ian King 

Variable minor is being assigned but never read, hence it is redundant
and can be removed. Cleans up clang warning:

drivers/usb/misc/adutux.c:770:2: warning: Value stored to 'minor' is
never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/misc/adutux.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index e9195a7103a8..4b8712733fc7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -757,13 +757,11 @@ static int adu_probe(struct usb_interface *interface,
 static void adu_disconnect(struct usb_interface *interface)
 {
struct adu_device *dev;
-   int minor;
 
dev = usb_get_intfdata(interface);
 
mutex_lock(>mtx);  /* not interruptible */
dev->udev = NULL;   /* poison */
-   minor = dev->minor;
usb_deregister_dev(interface, _class);
mutex_unlock(>mtx);
 
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: remove redundant assignment to temp

2017-11-07 Thread Colin King
From: Colin Ian King 

The variable temp is being set at the end of each loop iteration
but this value is never read, it is either being updated in just
the case 1 block or at the end of the loop.  Thus the assignment
is redundant and can be removed.  Cleans up clang warning:

drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/ehci-dbg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 7fb21d01b3d0..70d4768958be 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -838,7 +838,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer 
*buf)
default:/* unknown */
break;
}
-   temp = (cap >> 8) & 0xff;
}
}
 #endif
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: udc: renesas_usb3: make const array max_packet_array static

2017-11-02 Thread Colin King
From: Colin Ian King 

Don't populate the const array max_packet_array on the stack, instead make
it static. Makes the object code smaller by over 90 bytes:

Before:
   textdata bss dec hex filename
  343375612 128   400779c8d renesas_usb3.o

After:
   textdata bss dec hex filename
  341495708 128   399859c31 renesas_usb3.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index ed84f5158a38..cb461b8f4509 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2058,7 +2058,7 @@ static u32 usb3_calc_rammap_val(struct renesas_usb3_ep 
*usb3_ep,
const struct usb_endpoint_descriptor *desc)
 {
int i;
-   const u32 max_packet_array[] = {8, 16, 32, 64, 512};
+   static const u32 max_packet_array[] = {8, 16, 32, 64, 512};
u32 mpkt = PN_RAMMAP_MPKT(1024);
 
for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) {
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: c67x00: remove redundant pointer urbp

2017-11-01 Thread Colin King
From: Colin Ian King 

Pointer urbp is assigned but is never read, hence it is redundant
and can be removed. Cleans up clang warning:

drivers/usb/c67x00/c67x00-sched.c:975:2: warning: Value stored to 'urbp'
is never read

Signed-off-by: Colin Ian King 
---
 drivers/usb/c67x00/c67x00-sched.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
index 7311ed61e99a..0b68cd6874d2 100644
--- a/drivers/usb/c67x00/c67x00-sched.c
+++ b/drivers/usb/c67x00/c67x00-sched.c
@@ -966,13 +966,11 @@ static void c67x00_handle_successful_td(struct c67x00_hcd 
*c67x00,
 static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td)
 {
struct urb *urb = td->urb;
-   struct c67x00_urb_priv *urbp;
int cnt;
 
if (!urb)
return;
 
-   urbp = urb->hcpriv;
cnt = td->privdata;
 
if (td->status & TD_ERROR_MASK)
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net: hso: remove redundant unused variable dev

2017-10-31 Thread Colin King
From: Colin Ian King 

The pointer dev is being assigned but is never used, hence it is
redundant and can be removed. Cleans up clang warning:

drivers/net/usb/hso.c:2280:2: warning: Value stored to 'dev' is
never read

Signed-off-by: Colin Ian King 
---
 drivers/net/usb/hso.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index d7a3379ea668..42d7edcc3106 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2263,7 +2263,6 @@ static void hso_serial_common_free(struct hso_serial 
*serial)
 static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
int rx_size, int tx_size)
 {
-   struct device *dev;
int minor;
int i;
 
@@ -2277,7 +2276,6 @@ static int hso_serial_common_create(struct hso_serial 
*serial, int num_urbs,
serial->parent->dev = tty_port_register_device_attr(>port,
tty_drv, minor, >parent->interface->dev,
serial->parent, hso_serial_dev_groups);
-   dev = serial->parent->dev;
 
/* fill in specific data for later use */
serial->minor = minor;
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: typec: wcove: fix uninitialized usbc_irq1 and usbc_irq2

2017-10-11 Thread Colin King
From: Colin Ian King 

Calls to regmap_read may fail with an -EINVAL return without setting
usbc_irq1 and usbc_irq2.  The error handling clean up expects these
to have been set (or zero on a failure) and currently may try to
clear the wrong IRQs if the uninitalized garbage values in usbc_irq1
or usbc_irq2 are non-zero.  The simplest fix is to ensure these
variables are initialized to zero.

Detected by CoverityScan, CID#1457737 ("Uninitialized scalar variable")

Fixes: 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support")
Signed-off-by: Colin Ian King 
---
 drivers/usb/typec/typec_wcove.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/typec_wcove.c b/drivers/usb/typec/typec_wcove.c
index a47a93ad34b7..4ce30a967962 100644
--- a/drivers/usb/typec/typec_wcove.c
+++ b/drivers/usb/typec/typec_wcove.c
@@ -441,8 +441,8 @@ static int wcove_read_rx_buffer(struct wcove_typec *wcove, 
void *msg)
 static irqreturn_t wcove_typec_irq(int irq, void *data)
 {
struct wcove_typec *wcove = data;
-   unsigned int usbc_irq1;
-   unsigned int usbc_irq2;
+   unsigned int usbc_irq1 = 0;
+   unsigned int usbc_irq2 = 0;
unsigned int cc1ctrl;
int ret;
 
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: storage: make const arrays static, reduces object code size

2017-09-12 Thread Colin King
From: Colin Ian King 

Don't populate const arrays on the stack, instead make them
static.  Makes the object code smaller by over 1070 bytes:

Before:
   textdata bss dec hex filename
   3505 880   043851121 drivers/usb/storage/option_ms.o

After:
   textdata bss dec hex filename
   22691040   03309 ced drivers/usb/storage/option_ms.o

Signed-off-by: Colin Ian King 
---
 drivers/usb/storage/option_ms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 57282f12317b..4a73cd4783ae 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem 
(default),"
 
 static int option_rezero(struct us_data *us)
 {
-   const unsigned char rezero_msg[] = {
+   static const unsigned char rezero_msg[] = {
  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
  0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -87,7 +87,7 @@ static int option_rezero(struct us_data *us)
 
 static int option_inquiry(struct us_data *us)
 {
-   const unsigned char inquiry_msg[] = {
+   static const unsigned char inquiry_msg[] = {
  0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,
  0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,
  0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: dummy: fix infinite loop because of missing loop decrement

2017-08-15 Thread Colin King
From: Colin Ian King 

The while loop never terminates because the loop counter i is never
decremented. Fix this by decrementing i.

Detected by CoverityScan, CID#751073 ("Infinite Loop")

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c 
b/drivers/usb/gadget/udc/dummy_hcd.c
index 3c3760315910..a030d7923d7d 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2776,7 +2776,7 @@ static int __init init(void)
if (retval < 0) {
i--;
while (i >= 0)
-   platform_device_del(the_udc_pdev[i]);
+   platform_device_del(the_udc_pdev[i--]);
goto err_add_udc;
}
}
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V2] usb: storage: return on error to avoid a null pointer dereference

2017-07-06 Thread Colin King
From: Colin Ian King 

When us->extra is null the driver is not initialized, however, a
later call to osd200_scsi_to_ata is made that dereferences
us->extra, causing a null pointer dereference.  The code
currently detects and reports that the driver is not initialized;
add a return to avoid the subsequent dereference issue in this
check.

Thanks to Alan Stern for pointing out that srb->result needs setting
to DID_ERROR << 16

Detected by CoverityScan, CID#100308 ("Dereference after null check")

Signed-off-by: Colin Ian King 
---
 drivers/usb/storage/isd200.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index fba4005dd737..6a7720e66595 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1529,8 +1529,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, 
struct us_data *us)
 
/* Make sure driver was initialized */
 
-   if (us->extra == NULL)
+   if (us->extra == NULL) {
usb_stor_dbg(us, "ERROR Driver not initialized\n");
+   srb->result = DID_ERROR << 16;
+   return;
+   }
 
scsi_set_resid(srb, 0);
/* scsi_bufflen might change in protocol translation to ata */
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: storage: return on error to avoid a null pointer dereference

2017-07-06 Thread Colin King
From: Colin Ian King 

When us->extra is null the driver is not initialized, however, a
later call to osd200_scsi_to_ata is made that dereferences
us->extra, causing a null pointer dereference.  The code
currently detects and reports that the driver is not initialized;
add a return to avoid the subsequent dereference issue in this
check.

Detected by CoverityScan, CID#100308 ("Dereference after null check")

Signed-off-by: Colin Ian King 
---
 drivers/usb/storage/isd200.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index fba4005dd737..174ad60679e7 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1529,8 +1529,10 @@ static void isd200_ata_command(struct scsi_cmnd *srb, 
struct us_data *us)
 
/* Make sure driver was initialized */
 
-   if (us->extra == NULL)
+   if (us->extra == NULL) {
usb_stor_dbg(us, "ERROR Driver not initialized\n");
+   return;
+   }
 
scsi_set_resid(srb, 0);
/* scsi_bufflen might change in protocol translation to ata */
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: make array type_array static const

2017-07-04 Thread Colin King
From: Colin Ian King 

Array type_array can be made static const rather than being
populated on the stack. Makes the object code smaller:

Before:
   textdata bss dec hex filename
   80871496   09583256f drivers/usb/renesas_usbhs/pipe.o

After:
   textdata bss dec hex filename
   78831584   0946724fb drivers/usb/renesas_usbhs/pipe.o

Signed-off-by: Colin Ian King 
---
 drivers/usb/renesas_usbhs/pipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 9396a8c14af8..d811f0550c04 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -401,7 +401,7 @@ static int usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, 
int is_host,
u16 dir = 0;
u16 epnum = 0;
u16 shtnak = 0;
-   u16 type_array[] = {
+   static const u16 type_array[] = {
[USB_ENDPOINT_XFER_BULK] = TYPE_BULK,
[USB_ENDPOINT_XFER_INT]  = TYPE_INT,
[USB_ENDPOINT_XFER_ISOC] = TYPE_ISO,
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: atm: ueagle-atm: fix spelling mistake: "submition" -> "submission"

2017-07-03 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in uea_err error message

Signed-off-by: Colin Ian King 
---
 drivers/usb/atm/ueagle-atm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index df67815f74e6..a7b69360949e 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2212,7 +2212,7 @@ static int uea_boot(struct uea_softc *sc)
ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
if (ret < 0) {
uea_err(INS_TO_USBDEV(sc),
-  "urb submition failed with error %d\n", ret);
+  "urb submission failed with error %d\n", ret);
goto err1;
}
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fsl_udc_core: fix spelling mistake: "Dectected" -> "Detected"

2017-05-14 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in seq_printf text

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index 6f2f71c054be..63ab3d50f3f6 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2067,7 +2067,7 @@ static int fsl_proc_read(struct seq_file *m, void *v)
"Sleep Enable: %d SOF Received Enable: %d "
"Reset Enable: %d\n"
"System Error Enable: %d "
-   "Port Change Dectected Enable: %d\n"
+   "Port Change Detected Enable: %d\n"
"USB Error Intr Enable: %d USB Intr Enable: %d\n\n",
(tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0,
(tmp_reg & USB_INTR_SOF_EN) ? 1 : 0,
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: pch_udc: don't update td->next after it has been released to the pool

2017-03-28 Thread Colin King
From: Colin Ian King 

Writing to td->next should be avoided after td has been freed using
dma_pool_free. The intent was to nullify the next pointer, but this
is potentially dangerous once it is back in the pool. Remove it.

Detected by CoverityScan, CID#1091173 ("Write tp pointer after free")

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/pch_udc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 84dcbcd756f0..08bbe2c24134 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1523,7 +1523,6 @@ static void pch_udc_free_dma_chain(struct pch_udc_dev 
*dev,
td = phys_to_virt(addr);
addr2 = (dma_addr_t)td->next;
dma_pool_free(dev->data_requests, td, addr);
-   td->next = 0x00;
addr = addr2;
}
req->chain_len = 1;
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: udc: remove redundant initial assignments to the pointer 's'

2017-03-27 Thread Colin King
From: Colin Ian King 

The initial setting of pointer s to the driver name or to the literal
string "(none)" is redundant as later it is always set to point to
a different literal string before it is printed log.  Remove this
redundant code.

Detected with CoverityScan, CID#1227032, CID#1227033 ("Unused Value")

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/net2272.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 8f85a51bd2b3..dee4eb60d4c2 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -1191,11 +1191,6 @@ registers_show(struct device *_dev, struct 
device_attribute *attr, char *buf)
size = PAGE_SIZE;
spin_lock_irqsave(>lock, flags);
 
-   if (dev->driver)
-   s = dev->driver->driver.name;
-   else
-   s = "(none)";
-
/* Main Control Registers */
t = scnprintf(next, size, "%s version %s,"
"chiprev %02x, locctl %02x\n"
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net: usb: asix_devices: fix missing return code check on call to asix_write_medium_mode

2017-02-28 Thread Colin King
From: Colin Ian King 

The call to asix_write_medium_mode is not updating the return code ret
and yet ret is being checked for an error. Fix this by assigning ret to
the return code from the call asix_write_medium_mode.

Detected by CoverityScan, CID#1357148 ("Logically Dead Code")

Signed-off-by: Colin Ian King 
---
 drivers/net/usb/asix_devices.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 6e98ede..0dd5106 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -346,7 +346,7 @@ static int ax88772_reset(struct usbnet *dev)
if (ret < 0)
goto out;
 
-   asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0);
+   ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0);
if (ret < 0)
goto out;
 
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-12 Thread Colin King
From: Colin Ian King 

The check for retval being less than zero is always true since
retval equal to -EPIPE at that point.  Replace the existing
conditional with just return retval.

Detected with CoverityScan, CID#114349 ("Logically dead code")

Signed-off-by: Colin Ian King 
---
 drivers/usb/misc/usbtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 3525626..17c0810 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
dev_err(>dev,
"hs dev qualifier --> %d\n",
retval);
-   return (retval < 0) ? retval : -EDOM;
+   return retval;
}
/* usb2.0 but not high-speed capable; fine */
} else if (retval != sizeof(struct usb_qualifier_descriptor)) {
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: storage: fix infinite wait loop by incrementing loop counter

2017-02-02 Thread Colin King
From: Colin Ian King 

If jumpshot_get_status continues to return a failed result then the
wait loop will spin forever because the waitcount counter is never
being incremented and we don't ever timeout.  Fix this by incrementing
waitcount.

Cc: 
Signed-off-by: Colin Ian King 
---
 drivers/usb/storage/jumpshot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index 011e527..81d82ce 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -311,6 +311,7 @@ static int jumpshot_write_data(struct us_data *us,
if (result != USB_STOR_TRANSPORT_GOOD) {
// I have not experimented to find the smallest 
value.
//
+   waitcount++;
msleep(50); 
}
} while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 
10));
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: misc: adutux: remove redundant error check on copy_to_user return code

2017-02-02 Thread Colin King
From: Colin Ian King 

The 2nd check for a non-zero return from copy_to_user is redundant as
it is has already been made a few lines earlier.  This check was made
redundant because of previous fix to the copy_to_user error return
check.

Detected by CoverityScan, CID#114347 ("Logically Dead Code")

Fixes: 1865a9c382ede ("USB: adutux: fix misuse of return value of 
copy_to_user()")

Signed-off-by: Colin Ian King 
---
 drivers/usb/misc/adutux.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 43a677f..c5fa584 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -389,10 +389,6 @@ static ssize_t adu_read(struct file *file, __user char 
*buffer, size_t count,
dev->secondary_head += (amount - i);
bytes_read += (amount - i);
bytes_to_read -= (amount - i);
-   if (i) {
-   retval = bytes_read ? bytes_read : -EFAULT;
-   goto exit;
-   }
} else {
/* we check the primary buffer */
spin_lock_irqsave (>buflock, flags);
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] HID: usbhid: Quirk a AMI virtual mouse and keyboard with ALWAYS_POLL

2017-01-26 Thread Colin King
From: Colin Ian King 

Quirking the following AMI USB device with ALWAYS_POLL fixes an AMI
virtual keyboard and mouse from not responding and timing out when
it is attached to a ppc64el Power 8 system and when we have some
rapid open/closes on the mouse device.

 usb 1-3: new high-speed USB device number 2 using xhci_hcd
 usb 1-3: New USB device found, idVendor=046b, idProduct=ff01
 usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
 usb 1-3: Product: Virtual Hub
 usb 1-3: Manufacturer: American Megatrends Inc.
 usb 1-3: SerialNumber: serial
 usb 1-3.3: new high-speed USB device number 3 using xhci_hcd
 usb 1-3.3: New USB device found, idVendor=046b, idProduct=ff31
 usb 1-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
 usb 1-3.3: Product: Virtual HardDisk Device
 usb 1-3.3: Manufacturer: American Megatrends Inc.
 usb 1-3.4: new low-speed USB device number 4 using xhci_hcd
 usb 1-3.4: New USB device found, idVendor=046b, idProduct=ff10
 usb 1-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
 usb 1-3.4: Product: Virtual Keyboard and Mouse
 usb 1-3.4: Manufacturer: American Megatrends Inc.

With the quirk I have not been able to trigger the issue with
half an hour of saturation soak testing.

Signed-off-by: Colin Ian King 
---
 drivers/hid/hid-ids.h   | 3 +++
 drivers/hid/usbhid/hid-quirks.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index e348865..45317d3 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -76,6 +76,9 @@
 #define USB_VENDOR_ID_ALPS_JP  0x044E
 #define HID_DEVICE_ID_ALPS_U1_DUAL 0x120B
 
+#define USB_VENDOR_ID_AMI  0x046b
+#define USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE  0xff10
+
 #define USB_VENDOR_ID_ANTON0x1130
 #define USB_DEVICE_ID_ANTON_TOUCH_PAD  0x3101
 
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 37d17f7..d6847a6 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -57,6 +57,7 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_AIREN, USB_DEVICE_ID_AIREN_SLIMPLUS, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_AKAI, USB_DEVICE_ID_AKAI_MPKMINI2, 
HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_AKAI_09E8, USB_DEVICE_ID_AKAI_09E8_MIDIMIX, 
HID_QUIRK_NO_INIT_REPORTS },
+   { USB_VENDOR_ID_AMI, USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE, 
HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: mod_host: fix typo: "connecte" -> "connected"

2016-12-28 Thread Colin King
From: Colin Ian King 

trivial fix to typo in dev_dbg message

Signed-off-by: Colin Ian King 
---
 drivers/usb/renesas_usbhs/mod_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index 165e81b..dfb346e 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -577,7 +577,7 @@ static struct usbhsh_device *usbhsh_device_attach(struct 
usbhsh_hpriv *hpriv,
upphub  = usbhsh_device_number(hpriv, parent);
hubport = usbhsh_device_hubport(udev);
 
-   dev_dbg(dev, "%s connecte to Hub [%d:%d](%p)\n", __func__,
+   dev_dbg(dev, "%s connected to Hub [%d:%d](%p)\n", __func__,
upphub, hubport, parent);
}
 
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V2] USB: wusbcore: add in missing white space in error message text

2016-09-12 Thread Colin King
From: Colin Ian King 

A dev_err message spans two lines and the literal string is missing
a white space between words. Add the white space and reformat the
message to not span multiple lines.

Signed-off-by: Colin Ian King 
---
 drivers/usb/wusbcore/cbaf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index da1b872..fb70cbef 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -610,8 +610,7 @@ static int cbaf_probe(struct usb_interface *iface,
cbaf->usb_iface = usb_get_intf(iface);
result = cbaf_check(cbaf);
if (result < 0) {
-   dev_err(dev, "This device is not WUSB-CBAF compliant"
-   "and is not supported yet.\n");
+   dev_err(dev, "This device is not WUSB-CBAF compliant and is not 
supported yet.\n");
goto error_check;
}
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: wusbcore: add in missing white space in error message text

2016-09-12 Thread Colin King
From: Colin Ian King 

A dev_err message spans two lines and the literal string is missing
a white space between words. Add the white space.

Signed-off-by: Colin Ian King 
---
 drivers/usb/wusbcore/cbaf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index da1b872..62ade9f 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -610,7 +610,7 @@ static int cbaf_probe(struct usb_interface *iface,
cbaf->usb_iface = usb_get_intf(iface);
result = cbaf_check(cbaf);
if (result < 0) {
-   dev_err(dev, "This device is not WUSB-CBAF compliant"
+   dev_err(dev, "This device is not WUSB-CBAF compliant "
"and is not supported yet.\n");
goto error_check;
}
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: remove variable ret and remove unnecessary if statement

2016-09-08 Thread Colin King
From: Colin Ian King 

the if statement in lb_modinit is unnecessary so we can totally
remove the variable ret and just return the return value from
the call to usb_function_register.

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/function/f_loopback.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index ddb8c89..e700938 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -591,13 +591,9 @@ DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, 
loopback_alloc);
 
 int __init lb_modinit(void)
 {
-   int ret;
-
-   ret = usb_function_register(_func);
-   if (ret)
-   return ret;
-   return ret;
+   return usb_function_register(_func);
 }
+
 void __exit lb_modexit(void)
 {
usb_function_unregister(_func);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: prevent potenial null pointer dereference on skb->len

2016-09-05 Thread Colin King
From: Colin Ian King 

An earlier fix partially fixed the null pointer dereference on skb->len
by moving the assignment of len after the check on skb being non-null,
however it failed to remove the erroneous dereference when assigning len.
Correctly fix this by removing the initialisation of len as was
originally intended.

Fixes: 70237dc8efd092 ("usb: gadget: function: f_eem: socket buffer may be 
NULL")
Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/function/f_eem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index 8741fd7..007ec6e 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -342,7 +342,7 @@ static struct sk_buff *eem_wrap(struct gether *port, struct 
sk_buff *skb)
struct sk_buff  *skb2 = NULL;
struct usb_ep   *in = port->in_ep;
int headroom, tailroom, padlen = 0;
-   u16 len = skb->len;
+   u16 len;
 
if (!skb)
return NULL;
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: phy: ab8500-usb: fix spelling mistake "regester" -> "register"

2016-08-28 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistakes in dev_err messages.

Signed-off-by: Colin Ian King 
---
 drivers/usb/phy/phy-ab8500-usb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 0c912d3..a03caf4 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -1248,7 +1248,7 @@ static void ab8500_usb_set_ab8500_tuning_values(struct 
ab8500_usb *ab)
err = abx500_set_register_interruptible(ab->dev,
AB8500_DEBUG, AB8500_USB_PHY_TUNE3, 0x78);
if (err < 0)
-   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 register err=%d\n",
err);
 
/* Switch to normal mode/disable Bank 0x12 access */
@@ -1290,7 +1290,7 @@ static void ab8500_usb_set_ab8505_tuning_values(struct 
ab8500_usb *ab)
0xFC, 0x80);
 
if (err < 0)
-   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 register err=%d\n",
err);
 
/* Switch to normal mode/disable Bank 0x12 access */
@@ -1321,7 +1321,7 @@ static void ab8500_usb_set_ab8540_tuning_values(struct 
ab8500_usb *ab)
err = abx500_set_register_interruptible(ab->dev,
AB8540_DEBUG, AB8500_USB_PHY_TUNE3, 0x90);
if (err < 0)
-   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester ret=%d\n",
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 register ret=%d\n",
err);
 }
 
@@ -1351,7 +1351,7 @@ static void ab8500_usb_set_ab9540_tuning_values(struct 
ab8500_usb *ab)
err = abx500_set_register_interruptible(ab->dev,
AB8500_DEBUG, AB8500_USB_PHY_TUNE3, 0x80);
if (err < 0)
-   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 register err=%d\n",
err);
 
/* Switch to normal mode/disable Bank 0x12 access */
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: net2280: fix typo: "Inavlid" -> "Invalid"

2016-08-24 Thread Colin King
From: Colin Ian King 

trivial typo fix in dev_err message

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 614ab951..d8c9ab4 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -589,7 +589,7 @@ static void net2280_free_request(struct usb_ep *_ep, struct 
usb_request *_req)
 
ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || !_req) {
-   dev_err(>dev->pdev->dev, "%s: Inavlid ep=%p or req=%p\n",
+   dev_err(>dev->pdev->dev, "%s: Invalid ep=%p or req=%p\n",
__func__, _ep, _req);
return;
}
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: remove redundant self assignment

2016-07-25 Thread Colin King
From: Colin Ian King 

The assignment ret = ret is redundant and can be removed.

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index ff8685e..48cf1a3 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -107,10 +107,8 @@ int usb_ep_enable(struct usb_ep *ep)
goto out;
 
ret = ep->ops->enable(ep, ep->desc);
-   if (ret) {
-   ret = ret;
+   if (ret)
goto out;
-   }
 
ep->enabled = true;
 
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: bdc: fix spelling mistake: "allocted" -> "allocated"

2016-06-03 Thread Colin King
From: Colin Ian King 

trivial fix to spelling mistake

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index d619950..b48b259 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -81,7 +81,7 @@ static void ep_bd_list_free(struct bdc_ep *ep, u32 num_tabs)
continue;
}
if (!bd_table->start_bd) {
-   dev_dbg(bdc->dev, "bd dma pool not allocted\n");
+   dev_dbg(bdc->dev, "bd dma pool not allocated\n");
continue;
}
 
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb/host/fotg210: remove dead code in create_sysfs_files

2016-05-08 Thread Colin King
From: Colin Ian King 

The goto in create_sysfs_files is never executed, so remove it
and clean up the code.

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/fotg210-hcd.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 360a5e9..66efa9a 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -4795,14 +4795,8 @@ static DEVICE_ATTR(uframe_periodic_max, 0644, 
show_uframe_periodic_max,
 static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
 {
struct device *controller = fotg210_to_hcd(fotg210)->self.controller;
-   int i = 0;
 
-   if (i)
-   goto out;
-
-   i = device_create_file(controller, _attr_uframe_periodic_max);
-out:
-   return i;
+   return device_create_file(controller, _attr_uframe_periodic_max);
 }
 
 static inline void remove_sysfs_files(struct fotg210_hcd *fotg210)
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: hcd: do not call whc_clean_up on wch_init call failure

2016-03-26 Thread Colin King
From: Colin Ian King 

whc_init already calls whc_clean_up if an error occurs during
the initialization, so calling it again if whc_init fails at
the end of wch_probe will cause double free errors.  Fix this
by bailing out on an whc_init failure to a new label that avoids
doing the duplicated whc_clean_up.

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/whci/hcd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c
index 43626c4..5b3603c 100644
--- a/drivers/usb/host/whci/hcd.c
+++ b/drivers/usb/host/whci/hcd.c
@@ -257,14 +257,14 @@ static int whc_probe(struct umc_dev *umc)
 
ret = whc_init(whc);
if (ret)
-   goto error;
+   goto error_whc_init;
 
wusbhc->dev = dev;
wusbhc->uwb_rc = uwb_rc_get_by_grandpa(umc->dev.parent);
if (!wusbhc->uwb_rc) {
ret = -ENODEV;
dev_err(dev, "cannot get radio controller\n");
-   goto error;
+   goto error_uwb_rc;
}
 
if (whc->n_devices > USB_MAXCHILDREN) {
@@ -311,8 +311,9 @@ error_usb_add_hcd:
wusbhc_destroy(wusbhc);
 error_wusbhc_create:
uwb_rc_put(wusbhc->uwb_rc);
-error:
+error_uwb_rc:
whc_clean_up(whc);
+error_whc_init:
usb_put_hcd(usb_hcd);
return ret;
 }
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] asix: do not free array priv->mdio->irq

2016-03-03 Thread Colin King
From: Colin Ian King 

Used to be allocated and required freeing, but now
priv->mdio->irq is now a fixed sized array and should no longer be
free'd.

Issue detected using static analysis with CoverityScan

Fixes: e7f4dc3536a400 ("mdio: Move allocation of interrupts into core")
Signed-off-by: Colin Ian King 
---
 drivers/net/usb/ax88172a.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
index 224e7d8..cf77f2d 100644
--- a/drivers/net/usb/ax88172a.c
+++ b/drivers/net/usb/ax88172a.c
@@ -134,7 +134,6 @@ static void ax88172a_remove_mdio(struct usbnet *dev)
 
netdev_info(dev->net, "deregistering mdio bus %s\n", priv->mdio->id);
mdiobus_unregister(priv->mdio);
-   kfree(priv->mdio->irq);
mdiobus_free(priv->mdio);
 }
 
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V3] usb: isp1760: check for null return from kzalloc

2015-06-02 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

isp1760_ep_alloc_request allocates a structure with kzalloc without checking 
for NULL and then returns a pointer to one of the structure fields. As the 
field happens to be the first in the structure the caller can properly check 
for NULL, but this is risky if the structure layout is changed later. Add an 
explicit NULL check for the kzalloc return value

Detected with smatch static analysis:

drivers/usb/isp1760/isp1760-udc.c:816 isp1760_ep_alloc_request()
  error: potential null dereference 'req'.  (kzalloc returns null)

[ thanks to Laurent Pinchart for improved commit message ]

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/isp1760/isp1760-udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/isp1760/isp1760-udc.c 
b/drivers/usb/isp1760/isp1760-udc.c
index 3fc4fe7..18ebf5b 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -812,6 +812,8 @@ static struct usb_request *isp1760_ep_alloc_request(struct 
usb_ep *ep,
struct isp1760_request *req;
 
req = kzalloc(sizeof(*req), gfp_flags);
+   if (!req)
+   return NULL;
 
return req-req;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: isp1760: fix null dereference if kzalloc returns null

2015-05-31 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

If kzalloc returns null then isp1760_ep_alloc_request performs
a null pointer deference on req. Check for null to avoid this.

Detected with smatch static analysis:

drivers/usb/isp1760/isp1760-udc.c:816 isp1760_ep_alloc_request()
  error: potential null dereference 'req'.  (kzalloc returns null)

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/isp1760/isp1760-udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/isp1760/isp1760-udc.c 
b/drivers/usb/isp1760/isp1760-udc.c
index 3fc4fe7..18ebf5b 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -812,6 +812,8 @@ static struct usb_request *isp1760_ep_alloc_request(struct 
usb_ep *ep,
struct isp1760_request *req;
 
req = kzalloc(sizeof(*req), gfp_flags);
+   if (!req)
+   return NULL;
 
return req-req;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V2] usb: isp1760: fix null dereference if kzalloc returns null

2015-05-31 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

If kzalloc returns null then isp1760_ep_alloc_request performs
a null pointer dereference on req. Check for null to avoid this.

Detected with smatch static analysis:

drivers/usb/isp1760/isp1760-udc.c:816 isp1760_ep_alloc_request()
  error: potential null dereference 'req'.  (kzalloc returns null)

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/isp1760/isp1760-udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/isp1760/isp1760-udc.c 
b/drivers/usb/isp1760/isp1760-udc.c
index 3fc4fe7..18ebf5b 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -812,6 +812,8 @@ static struct usb_request *isp1760_ep_alloc_request(struct 
usb_ep *ep,
struct isp1760_request *req;
 
req = kzalloc(sizeof(*req), gfp_flags);
+   if (!req)
+   return NULL;
 
return req-req;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][V2] drivers/usb/serial/mos7840.c: remove unused code

2015-01-19 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

There is old, unused code that is #defined out by the
use of NOTMOS7840 and NOTMCS7840 - these are not
defined anywhere.

If NOTMOS7840 is defined then the code will break on null
pointer dereferences on mos7840_port.  So the code is
currently unused, and broken anyway, so why not just
remove it.

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/serial/mos7840.c | 60 
 1 file changed, 60 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 220b4be..e4473a9 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1309,35 +1309,6 @@ static int mos7840_write(struct tty_struct *tty, struct 
usb_serial_port *port,
const unsigned char *current_position = data;
unsigned char *data1;
 
-#ifdef NOTMOS7840
-   Data = 0x00;
-   status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-   mos7840_port-shadowLCR = Data;
-   dev_dbg(port-dev, %s: LINE_CONTROL_REGISTER is %x\n, __func__, 
Data);
-   dev_dbg(port-dev, %s: mos7840_port-shadowLCR is %x\n, __func__, 
mos7840_port-shadowLCR);
-
-   /* Data = 0x03; */
-   /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
-   /* mos7840_port-shadowLCR=Data;//Need to add later */
-
-   Data |= SERIAL_LCR_DLAB;/* data latch enable in LCR 0x80 */
-   status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-
-   /* Data = 0x0c; */
-   /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
-   Data = 0x00;
-   status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, Data);
-   dev_dbg(port-dev, %s: DLL value is %x\n, __func__, Data);
-
-   Data = 0x0;
-   status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, Data);
-   dev_dbg(port-dev, %s: DLM value is %x\n, __func__, Data);
-
-   Data = Data  ~SERIAL_LCR_DLAB;
-   dev_dbg(port-dev, %s: mos7840_port-shadowLCR is %x\n, __func__, 
mos7840_port-shadowLCR);
-   status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-#endif
-
if (mos7840_port_paranoia_check(port, __func__))
return -1;
 
@@ -1614,37 +1585,6 @@ static int mos7840_calc_baud_rate_divisor(struct 
usb_serial_port *port,
*clk_sel_val = 0x70;
}
return 0;
-
-#ifdef NOTMCS7840
-
-   for (i = 0; i  ARRAY_SIZE(mos7840_divisor_table); i++) {
-   if (mos7840_divisor_table[i].BaudRate == baudrate) {
-   *divisor = mos7840_divisor_table[i].Divisor;
-   return 0;
-   }
-   }
-
-   /* After trying for all the standard baud rates*
-* Try calculating the divisor for this baud rate  */
-
-   if (baudrate  75  baudrate  230400) {
-   /* get the divisor */
-   custom = (__u16) (230400L / baudrate);
-
-   /* Check for round off */
-   round1 = (__u16) (2304000L / baudrate);
-   round = (__u16) (round1 - (custom * 10));
-   if (round  4)
-   custom++;
-   *divisor = custom;
-
-   dev_dbg(port-dev,  Baud %d = %d\n, baudrate, custom);
-   return 0;
-   }
-
-   dev_dbg(port-dev, %s,  Baud calculation Failed...\n);
-   return -1;
-#endif
 }
 
 /*
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/usb/serial/mos7840.c: remove unused code

2015-01-13 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

There is old, unused code that is #defined out by the
use of NOTMOS7840 - this is not defined anywhere.  If
NOTMOS7840 is defined then the code will break on null
pointer dereferences on mos7840_port.  So the code is
currently unused, and broken anyway, so why not just
remove it.

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/serial/mos7840.c | 29 -
 1 file changed, 29 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 220b4be..ba718ea 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1309,35 +1309,6 @@ static int mos7840_write(struct tty_struct *tty, struct 
usb_serial_port *port,
const unsigned char *current_position = data;
unsigned char *data1;
 
-#ifdef NOTMOS7840
-   Data = 0x00;
-   status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-   mos7840_port-shadowLCR = Data;
-   dev_dbg(port-dev, %s: LINE_CONTROL_REGISTER is %x\n, __func__, 
Data);
-   dev_dbg(port-dev, %s: mos7840_port-shadowLCR is %x\n, __func__, 
mos7840_port-shadowLCR);
-
-   /* Data = 0x03; */
-   /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
-   /* mos7840_port-shadowLCR=Data;//Need to add later */
-
-   Data |= SERIAL_LCR_DLAB;/* data latch enable in LCR 0x80 */
-   status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-
-   /* Data = 0x0c; */
-   /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
-   Data = 0x00;
-   status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, Data);
-   dev_dbg(port-dev, %s: DLL value is %x\n, __func__, Data);
-
-   Data = 0x0;
-   status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, Data);
-   dev_dbg(port-dev, %s: DLM value is %x\n, __func__, Data);
-
-   Data = Data  ~SERIAL_LCR_DLAB;
-   dev_dbg(port-dev, %s: mos7840_port-shadowLCR is %x\n, __func__, 
mos7840_port-shadowLCR);
-   status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
-#endif
-
if (mos7840_port_paranoia_check(port, __func__))
return -1;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: usb3503: return correct error return on failure

2014-06-29 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

Fix warning: drivers/usb/misc/usb3503.c:195:11: warning: 'err'
  may be used uninitialized in this function [-Wmaybe-uninitialized]

err is not initialized, the error return should be PTR_ERR(clk)

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/misc/usb3503.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index f43c619..c0c898d 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -192,7 +192,8 @@ static int usb3503_probe(struct usb3503 *hub)
 
clk = devm_clk_get(dev, refclk);
if (IS_ERR(clk)  PTR_ERR(clk) != -ENOENT) {
-   dev_err(dev, unable to request refclk (%d)\n, err);
+   dev_err(dev, unable to request refclk (%ld)\n,
+   PTR_ERR(clk));
return PTR_ERR(clk);
}
 
-- 
2.0.0

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: misc: sisusbvga: Avoid NULL pointer dereference from sisusb

2013-03-15 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

A failed kzalloc() is reported with a dev_err that dereferences the null
sisusb, this will cause a NULL pointer deference error.

Instead, pass dev-dev to the dev_err() rather than sisusb-sisusb_dev-dev

Smatch analysis:

drivers/usb/misc/sisusbvga/sisusb.c:3087 sisusb_probe() error: potential null
  dereference 'sisusb'.  (kzalloc returns null)

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/usb/misc/sisusbvga/sisusb.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c 
b/drivers/usb/misc/sisusbvga/sisusb.c
index dd573ab..c21386e 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3084,7 +3084,7 @@ static int sisusb_probe(struct usb_interface *intf,
 
/* Allocate memory for our private */
if (!(sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL))) {
-   dev_err(sisusb-sisusb_dev-dev, Failed to allocate memory 
for private data\n);
+   dev_err(dev-dev, Failed to allocate memory for private 
data\n);
return -ENOMEM;
}
kref_init(sisusb-kref);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html