* re: Bluetooth: hciuart: Add support QCA chipset for UART
@ 2015-08-13 20:59 Dan Carpenter
2015-08-13 21:51 ` Ben Young Tae Kim
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2015-08-13 20:59 UTC (permalink / raw)
To: ytkim; +Cc: linux-bluetooth
Hello Ben Young Tae Kim,
The patch 0ff252c1976d: "Bluetooth: hciuart: Add support QCA chipset
for UART" from Aug 10, 2015, leads to the following static checker
warning:
drivers/bluetooth/hci_qca.c:485 qca_debugfs_init()
warn: passing casted pointer '&qca->tx_vote' to 'debugfs_create_bool()' 1 vs 32.
drivers/bluetooth/hci_qca.c
482 &qca->ibs_recv_wakes);
483 debugfs_create_u64("ibs_recv_wake_acks", mode, ibs_dir,
484 &qca->ibs_recv_wacks);
485 debugfs_create_bool("tx_vote", mode, ibs_dir, (u32 *)&qca->tx_vote);
debugfs_create_bool() is stupid, because the name says bool but it
writes a u32. I am not sure why this is. Maybe because the sizeof
_Bool is not defined in C? Anyway, this will not work and will also
corrupt memory.
486 debugfs_create_u64("tx_votes_on", mode, ibs_dir, &qca->tx_votes_on);
487 debugfs_create_u64("tx_votes_off", mode, ibs_dir, &qca->tx_votes_off);
488 debugfs_create_bool("rx_vote", mode, ibs_dir, (u32 *)&qca->rx_vote);
^^^^
Same.
489 debugfs_create_u64("rx_votes_on", mode, ibs_dir, &qca->rx_votes_on);
490 debugfs_create_u64("rx_votes_off", mode, ibs_dir, &qca->rx_votes_off);
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bluetooth: hciuart: Add support QCA chipset for UART
2015-08-13 20:59 Bluetooth: hciuart: Add support QCA chipset for UART Dan Carpenter
@ 2015-08-13 21:51 ` Ben Young Tae Kim
2015-08-13 21:59 ` Ben Young Tae Kim
0 siblings, 1 reply; 4+ messages in thread
From: Ben Young Tae Kim @ 2015-08-13 21:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-bluetooth
Hi Dan,
On 08/13/15 13:59, Dan Carpenter wrote:
> Hello Ben Young Tae Kim,
>
> The patch 0ff252c1976d: "Bluetooth: hciuart: Add support QCA chipset
> for UART" from Aug 10, 2015, leads to the following static checker
> warning:
>
> drivers/bluetooth/hci_qca.c:485 qca_debugfs_init()
> warn: passing casted pointer '&qca->tx_vote' to 'debugfs_create_bool()' 1 vs 32.
>
> drivers/bluetooth/hci_qca.c
> 482 &qca->ibs_recv_wakes);
> 483 debugfs_create_u64("ibs_recv_wake_acks", mode, ibs_dir,
> 484 &qca->ibs_recv_wacks);
> 485 debugfs_create_bool("tx_vote", mode, ibs_dir, (u32 *)&qca->tx_vote);
>
> debugfs_create_bool() is stupid, because the name says bool but it
> writes a u32. I am not sure why this is. Maybe because the sizeof
> _Bool is not defined in C? Anyway, this will not work and will also
> corrupt memory.
I agree with you. The reason why I do the cast as u32 type pointer is
debugfs_create_bool() function is required to put value as u32 *. But it
will cause memory corruption to read that because it is actual 1 byte.
Thanks for your report. I'll submit the patch to address it soon.
>
> 486 debugfs_create_u64("tx_votes_on", mode, ibs_dir, &qca->tx_votes_on);
> 487 debugfs_create_u64("tx_votes_off", mode, ibs_dir, &qca->tx_votes_off);
> 488 debugfs_create_bool("rx_vote", mode, ibs_dir, (u32 *)&qca->rx_vote);
> ^^^^
> Same.
>
> 489 debugfs_create_u64("rx_votes_on", mode, ibs_dir, &qca->rx_votes_on);
> 490 debugfs_create_u64("rx_votes_off", mode, ibs_dir, &qca->rx_votes_off);
>
>
>
> regards,
> dan carpenter
Thanks
-- Ben Kim
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bluetooth: hciuart: Add support QCA chipset for UART
2015-08-13 21:51 ` Ben Young Tae Kim
@ 2015-08-13 21:59 ` Ben Young Tae Kim
2015-08-14 0:40 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Ben Young Tae Kim @ 2015-08-13 21:59 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-bluetooth
Hi Dan,
On 08/13/15 14:51, Ben Young Tae Kim wrote:
> Hi Dan,
>
> On 08/13/15 13:59, Dan Carpenter wrote:
>> Hello Ben Young Tae Kim,
>>
>> The patch 0ff252c1976d: "Bluetooth: hciuart: Add support QCA chipset
>> for UART" from Aug 10, 2015, leads to the following static checker
>> warning:
>>
BTW, which tool are you using to detect static warning? Can you
recommend me some tool so that I could prevent same error to the
upcoming patches?
Thanks
-- Ben Kim
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bluetooth: hciuart: Add support QCA chipset for UART
2015-08-13 21:59 ` Ben Young Tae Kim
@ 2015-08-14 0:40 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-08-14 0:40 UTC (permalink / raw)
To: Ben Young Tae Kim; +Cc: linux-bluetooth
On Thu, Aug 13, 2015 at 02:59:30PM -0700, Ben Young Tae Kim wrote:
> BTW, which tool are you using to detect static warning? Can you
> recommend me some tool so that I could prevent same error to the
> upcoming patches?
>
This test is a Smatch test but it has too many false positives to
publish. Many of them can probably be silenced... I will see what I
can do.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-14 0:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 20:59 Bluetooth: hciuart: Add support QCA chipset for UART Dan Carpenter
2015-08-13 21:51 ` Ben Young Tae Kim
2015-08-13 21:59 ` Ben Young Tae Kim
2015-08-14 0:40 ` Dan Carpenter
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).