* [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset
@ 2022-10-17 3:04 Jiapeng Chong
2022-10-19 23:10 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 4+ messages in thread
From: Jiapeng Chong @ 2022-10-17 3:04 UTC (permalink / raw)
To: marcel
Cc: johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
linux-bluetooth, netdev, linux-kernel, Jiapeng Chong, Abaci Robot
Use kzalloc rather than duplicating its implementation, which makes code
simple and easy to understand.
./net/bluetooth/hci_conn.c:2038:6-13: WARNING: kzalloc should be used for cp, instead of kmalloc/memset.
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2406
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
net/bluetooth/hci_conn.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5d6ee5075642..495de21d52cd 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -2035,13 +2035,12 @@ int hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, __u8 dst_type,
if (hci_dev_test_and_set_flag(hdev, HCI_PA_SYNC))
return -EBUSY;
- cp = kmalloc(sizeof(*cp), GFP_KERNEL);
+ cp = kzalloc(sizeof(*cp), GFP_KERNEL);
if (!cp) {
hci_dev_clear_flag(hdev, HCI_PA_SYNC);
return -ENOMEM;
}
- memset(cp, 0, sizeof(*cp));
cp->sid = sid;
cp->addr_type = dst_type;
bacpy(&cp->addr, dst);
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset
2022-10-17 3:04 [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset Jiapeng Chong
@ 2022-10-19 23:10 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2022-10-19 23:10 UTC (permalink / raw)
To: Jiapeng Chong
Cc: marcel, johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
linux-bluetooth, netdev, linux-kernel, abaci
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Mon, 17 Oct 2022 11:04:21 +0800 you wrote:
> Use kzalloc rather than duplicating its implementation, which makes code
> simple and easy to understand.
>
> ./net/bluetooth/hci_conn.c:2038:6-13: WARNING: kzalloc should be used for cp, instead of kmalloc/memset.
>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2406
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>
> [...]
Here is the summary with links:
- net: bluetooth: Use kzalloc instead of kmalloc/memset
https://git.kernel.org/bluetooth/bluetooth-next/c/b0a19a2c4c53
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset
@ 2022-10-29 20:45 Kang Minchul
2022-10-31 23:10 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 4+ messages in thread
From: Kang Minchul @ 2022-10-29 20:45 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-bluetooth, netdev, linux-kernel, Kang Minchul
This commit replace kmalloc + memset to kzalloc
for better code readability and simplicity.
Following messages are related cocci warnings.
WARNING: kzalloc should be used for d, instead of kmalloc/memset
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
net/bluetooth/hci_conn.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 7a59c4487050..287d313aa312 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -824,11 +824,10 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis)
bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis);
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d)
return -ENOMEM;
- memset(d, 0, sizeof(*d));
d->big = big;
d->bis = bis;
@@ -861,11 +860,10 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle)
bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle);
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d)
return -ENOMEM;
- memset(d, 0, sizeof(*d));
d->big = big;
d->sync_handle = sync_handle;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset
2022-10-29 20:45 Kang Minchul
@ 2022-10-31 23:10 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2022-10-31 23:10 UTC (permalink / raw)
To: Kang Minchul
Cc: marcel, johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
linux-bluetooth, netdev, linux-kernel
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Sun, 30 Oct 2022 05:45:41 +0900 you wrote:
> This commit replace kmalloc + memset to kzalloc
> for better code readability and simplicity.
>
> Following messages are related cocci warnings.
>
> WARNING: kzalloc should be used for d, instead of kmalloc/memset
>
> [...]
Here is the summary with links:
- net: bluetooth: Use kzalloc instead of kmalloc/memset
https://git.kernel.org/bluetooth/bluetooth-next/c/214c507d87cc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-31 23:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-17 3:04 [PATCH] net: bluetooth: Use kzalloc instead of kmalloc/memset Jiapeng Chong
2022-10-19 23:10 ` patchwork-bot+bluetooth
-- strict thread matches above, loose matches on Subject: below --
2022-10-29 20:45 Kang Minchul
2022-10-31 23:10 ` patchwork-bot+bluetooth
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).