From: Khalid Masum <khalid.masum.92@gmail.com>
To: linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel@vger.kernel.org
Cc: Shuah Khan <skhan@linuxfoundation.org>,
Pavel Skripkin <paskripkin@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
Khalid Masum <khalid.masum.92@gmail.com>
Subject: [PATCH] Bluetooth: hci_core: Use ERR_PTR instead of NULL
Date: Sun, 17 Jul 2022 19:37:58 +0600 [thread overview]
Message-ID: <20220717133759.8479-1-khalid.masum.92@gmail.com> (raw)
Failure of kzalloc to allocate memory is not reported. Return Error
pointer to ENOMEM if memory allocation fails. This will increase
readability and will make the function easier to use in future.
Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
---
drivers/bluetooth/btusb.c | 4 ++--
net/bluetooth/hci_core.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index e25fcd49db70..3407762b3b15 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3692,8 +3692,8 @@ static int btusb_probe(struct usb_interface *intf,
data->recv_acl = hci_recv_frame;
hdev = hci_alloc_dev_priv(priv_size);
- if (!hdev)
- return -ENOMEM;
+ if (IS_ERR(hdev))
+ return PTR_ERR(hdev);
hdev->bus = HCI_USB;
hci_set_drvdata(hdev, data);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a0f99baafd35..ea50767e02bf 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2419,7 +2419,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)
hdev = kzalloc(alloc_size, GFP_KERNEL);
if (!hdev)
- return NULL;
+ return ERR_PTR(-ENOMEM);
hdev->pkt_type = (HCI_DM1 | HCI_DH1 | HCI_HV1);
hdev->esco_type = (ESCO_HV1);
--
2.36.1
next reply other threads:[~2022-07-17 13:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-17 13:37 Khalid Masum [this message]
2022-07-17 14:04 ` Bluetooth: hci_core: Use ERR_PTR instead of NULL bluez.test.bot
2022-07-17 16:17 ` [PATCH] " Pavel Skripkin
2022-07-17 18:34 ` Khalid Masum
2022-07-18 23:03 ` Luiz Augusto von Dentz
2022-07-23 10:54 ` Khalid Masum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220717133759.8479-1-khalid.masum.92@gmail.com \
--to=khalid.masum.92@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paskripkin@gmail.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).