diff mbox series

xhci: Fix sizeof() mismatch

Message ID 20201008171151.198996-1-colin.king@canonical.com (mailing list archive)
State Accepted
Commit a75e2d604da8219d928be010bde37c3ab0ebd466
Headers show
Series xhci: Fix sizeof() mismatch | expand

Commit Message

Colin King Oct. 8, 2020, 5:11 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

An incorrect sizeof() is being used, sizeof(rhub->ports) is not
correct, it should be sizeof(*rhub->ports).  This bug did not
cause any issues because it just so happens the sizes are the same.

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: bcaa9d5c5900 ("xhci: Create new structures to store xhci port information")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/usb/host/xhci-mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mathias Nyman Oct. 26, 2020, 1:46 p.m. UTC | #1
On 8.10.2020 20.11, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> An incorrect sizeof() is being used, sizeof(rhub->ports) is not
> correct, it should be sizeof(*rhub->ports).  This bug did not
> cause any issues because it just so happens the sizes are the same.
> 
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: bcaa9d5c5900 ("xhci: Create new structures to store xhci port information")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Thanks, added

-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index fe405cd38dbc..138ba4528dd3 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2252,8 +2252,8 @@  static void xhci_create_rhub_port_array(struct xhci_hcd *xhci,
 
 	if (!rhub->num_ports)
 		return;
-	rhub->ports = kcalloc_node(rhub->num_ports, sizeof(rhub->ports), flags,
-			dev_to_node(dev));
+	rhub->ports = kcalloc_node(rhub->num_ports, sizeof(*rhub->ports),
+			flags, dev_to_node(dev));
 	for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
 		if (xhci->hw_ports[i].rhub != rhub ||
 		    xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY)