public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [BlueZ PATCH v2 2/2] hog-lib: Fix scan-build error
Date: Tue, 16 Aug 2022 15:05:48 -0700	[thread overview]
Message-ID: <20220816220548.1555673-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20220816220548.1555673-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes the following errors:
profiles/input/hog-lib.c:600:19: warning: Access to field 'handle'
results in a dereference of a null pointer (loaded from variable 'chr')
        report->handle = chr->handle;
                         ^~~~~~~~~~~
profiles/input/hog-lib.c:637:11: warning: Access to field 'value_handle'
results in a dereference of a null pointer (loaded from variable 'chr')
                start = chr->value_handle + 1;
                        ^~~~~~~~~~~~~~~~~
profiles/input/hog-lib.c:1240:11: warning: Access to field 'value_handle'
results in a dereference of a null pointer (loaded from variable 'chr')
                start = chr->value_handle + 1;
                        ^~~~~~~~~~~~~~~~~
---
 profiles/input/hog-lib.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index ace233d3ce8b..021db386f3b7 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -590,6 +590,9 @@ static struct report *report_new(struct bt_hog *hog, struct gatt_char *chr)
 	struct report *report;
 	GSList *l;
 
+	if (!chr)
+		return NULL;
+
 	/* Skip if report already exists */
 	l = g_slist_find_custom(hog->reports, chr, report_chrc_cmp);
 	if (l)
@@ -630,6 +633,9 @@ static void external_service_char_cb(uint8_t status, GSList *chars,
 		chr = l->data;
 		next = l->next ? l->next->data : NULL;
 
+		if (!chr)
+			continue;
+
 		DBG("0x%04x UUID: %s properties: %02x",
 				chr->handle, chr->uuid, chr->properties);
 
@@ -1232,6 +1238,9 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
 		chr = l->data;
 		next = l->next ? l->next->data : NULL;
 
+		if (!chr)
+			continue;
+
 		DBG("0x%04x UUID: %s properties: %02x",
 				chr->handle, chr->uuid, chr->properties);
 
-- 
2.37.2


  reply	other threads:[~2022-08-16 22:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 22:05 [BlueZ PATCH v2 1/2] hog-lib: Don't restrict Report MAP size Luiz Augusto von Dentz
2022-08-16 22:05 ` Luiz Augusto von Dentz [this message]
2022-08-16 23:13 ` [BlueZ,v2,1/2] " bluez.test.bot
2022-08-16 23:20 ` [BlueZ PATCH v2 1/2] " patchwork-bot+bluetooth

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=20220816220548.1555673-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox