All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roushan Kumar Singh <github.rtron18@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Roushan Kumar Singh <github.rtron18@gmail.com>
Subject: [PATCH] Add Null Pointer Checks
Date: Sun,  1 Feb 2026 14:16:44 +0530	[thread overview]
Message-ID: <20260201084655.73566-1-github.rtron18@gmail.com> (raw)

---
 src/device.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/device.c b/src/device.c
index af8df5f29..c0b95d09c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -380,6 +380,9 @@ static GSList *find_service_with_uuid(GSList *list, char *uuid)
 		struct btd_service *service = l->data;
 		struct btd_profile *profile = btd_service_get_profile(service);
 
+		if (!profile || !profile->remote_uuid)
+			continue;
+
 		if (bt_uuid_strcmp(profile->remote_uuid, uuid) == 0)
 			return l;
 	}
@@ -2540,7 +2543,7 @@ static struct btd_service *find_connectable_service(struct btd_device *dev,
 		struct btd_service *service = l->data;
 		struct btd_profile *p = btd_service_get_profile(service);
 
-		if (!p->connect || !p->remote_uuid)
+		if (!p || !p->connect || !p->remote_uuid)
 			continue;
 
 		if (strcasecmp(uuid, p->remote_uuid) == 0)
@@ -2594,6 +2597,9 @@ void btd_device_update_allowed_services(struct btd_device *dev)
 		service = l->data;
 		profile = btd_service_get_profile(service);
 
+		if (!profile || !profile->remote_uuid)
+			continue;
+
 		is_allowed = btd_adapter_is_uuid_allowed(adapter,
 							profile->remote_uuid);
 		btd_service_set_allowed(service, is_allowed);
@@ -2629,11 +2635,12 @@ static GSList *create_pending_list(struct btd_device *dev, const char *uuid)
 		service = l->data;
 		p = btd_service_get_profile(service);
 
-		if (!p->auto_connect)
+		if (!p || !p->auto_connect)
 			continue;
 
 		if (!btd_service_is_allowed(service)) {
-			info("service %s is blocked", p->remote_uuid);
+			if (p->remote_uuid)
+				info("service %s is blocked", p->remote_uuid);
 			continue;
 		}
 
@@ -6173,8 +6180,8 @@ static void disconnect_gatt_service(gpointer data, gpointer user_data)
 	struct btd_service *service = data;
 	struct btd_profile *profile = btd_service_get_profile(service);
 
-	/* Ignore if profile cannot accept connections */
-	if (!profile->accept)
+	/* Ignore if profile is NULL or cannot accept connections */
+	if (!profile || !profile->accept)
 		return;
 
 	btd_service_disconnect(service);
-- 
2.51.0


             reply	other threads:[~2026-02-01  8:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01  8:46 Roushan Kumar Singh [this message]
2026-02-01  9:46 ` Add Null Pointer Checks bluez.test.bot
2026-02-03 21:51 ` [PATCH] " Luiz Augusto von Dentz

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=20260201084655.73566-1-github.rtron18@gmail.com \
    --to=github.rtron18@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.