* [PATCH v2] Fix application of sizeof to pointer
@ 2021-10-12 6:50 davidcomponentone
2021-10-12 7:01 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-10-12 6:50 UTC (permalink / raw)
To: jdike
Cc: joe, richard, anton.ivanov, johannes.berg, davidcomponentone,
linux-um, linux-kernel, Zeal Robot
From: David Yang <davidcomponentone@gmail.com>
The coccinelle check report:
"./arch/um/drivers/virt-pci.c:192:20-26:
ERROR: application of sizeof to pointer"
Using the "sizeof(buf->data)" to fix it.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
---
arch/um/drivers/virt-pci.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index c08066633023..9333edd71604 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -187,9 +187,8 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
return ~0ULL;
buf = get_cpu_var(um_pci_msg_bufs);
- data = buf->data;
- memset(data, 0xff, sizeof(data));
+ memset(buf->data, 0xff, sizeof(buf->data));
switch (size) {
case 1:
@@ -204,22 +203,22 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
goto out;
}
- if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, 8))
+ if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, buf->data, 8))
goto out;
switch (size) {
case 1:
- ret = data[0];
+ ret = buf->data[0];
break;
case 2:
- ret = le16_to_cpup((void *)data);
+ ret = le16_to_cpup((void *)buf->data);
break;
case 4:
- ret = le32_to_cpup((void *)data);
+ ret = le32_to_cpup((void *)buf->data);
break;
#ifdef CONFIG_64BIT
case 8:
- ret = le64_to_cpup((void *)data);
+ ret = le64_to_cpup((void *)buf->data);
break;
#endif
default:
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Fix application of sizeof to pointer
2021-10-12 6:50 [PATCH v2] Fix application of sizeof to pointer davidcomponentone
@ 2021-10-12 7:01 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2021-10-12 7:01 UTC (permalink / raw)
To: davidcomponentone, jdike
Cc: richard, anton.ivanov, johannes.berg, linux-um, linux-kernel, Zeal Robot
On Tue, 2021-10-12 at 14:50 +0800, davidcomponentone@gmail.com wrote:
> From: David Yang <davidcomponentone@gmail.com>
>
> The coccinelle check report:
> "./arch/um/drivers/virt-pci.c:192:20-26:
> ERROR: application of sizeof to pointer"
> Using the "sizeof(buf->data)" to fix it.
Try compiling this with W=1 or just maybe even just compiling your change.
You've now got an unused declaration of u8 *data;
> diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
[]
> @@ -187,9 +187,8 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
> return ~0ULL;
>
> buf = get_cpu_var(um_pci_msg_bufs);
> - data = buf->data;
>
> - memset(data, 0xff, sizeof(data));
> + memset(buf->data, 0xff, sizeof(buf->data));
> switch (size) {
> case 1:
> @@ -204,22 +203,22 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
> goto out;
> }
>
> - if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, 8))
> + if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, buf->data, 8))
> goto out;
>
> switch (size) {
> case 1:
> - ret = data[0];
> + ret = buf->data[0];
> break;
> case 2:
> - ret = le16_to_cpup((void *)data);
> + ret = le16_to_cpup((void *)buf->data);
> break;
> case 4:
> - ret = le32_to_cpup((void *)data);
> + ret = le32_to_cpup((void *)buf->data);
> break;
> #ifdef CONFIG_64BIT
> case 8:
> - ret = le64_to_cpup((void *)data);
> + ret = le64_to_cpup((void *)buf->data);
> break;
> #endif
> default:
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Fix application of sizeof to pointer
@ 2021-10-13 0:56 davidcomponentone
2021-10-13 6:37 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-10-13 0:56 UTC (permalink / raw)
To: marcel
Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
David Yang, Zeal Robot
From: David Yang <davidcomponentone@gmail.com>
The coccinelle check report:
"./drivers/bluetooth/btusb.c:2239:36-42:
ERROR: application of sizeof to pointer".
Using the real size to fix it.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
---
drivers/bluetooth/btusb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 75c83768c257..3e26f60b457e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2236,7 +2236,7 @@ static int btusb_set_bdaddr_mtk(struct hci_dev *hdev, const bdaddr_t *bdaddr)
struct sk_buff *skb;
long ret;
- skb = __hci_cmd_sync(hdev, 0xfc1a, sizeof(bdaddr), bdaddr, HCI_INIT_TIMEOUT);
+ skb = __hci_cmd_sync(hdev, 0xfc1a, 6, bdaddr, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
ret = PTR_ERR(skb);
bt_dev_err(hdev, "changing Mediatek device address failed (%ld)",
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Fix application of sizeof to pointer
2021-10-13 0:56 davidcomponentone
@ 2021-10-13 6:37 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2021-10-13 6:37 UTC (permalink / raw)
To: davidcomponentone
Cc: Johan Hedberg, Luiz Augusto von Dentz, linux-bluetooth,
Linux Kernel Mailing List, Zeal Robot
Hi David,
> The coccinelle check report:
> "./drivers/bluetooth/btusb.c:2239:36-42:
> ERROR: application of sizeof to pointer".
> Using the real size to fix it.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: David Yang <davidcomponentone@gmail.com>
> ---
> drivers/bluetooth/btusb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-13 6:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 6:50 [PATCH v2] Fix application of sizeof to pointer davidcomponentone
2021-10-12 7:01 ` Joe Perches
2021-10-13 0:56 davidcomponentone
2021-10-13 6:37 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).