From: "Gustavo F. Padovan" <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: gustavo@padovan.org
Subject: [PATCH 3/3] sdptool: Fix 2 possible NULL dereference
Date: Sat, 5 Jun 2010 07:14:30 -0300 [thread overview]
Message-ID: <1275732870-15889-4-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1275732870-15889-3-git-send-email-gustavo@padovan.org>
Issues found by smatch static check:
http://smatch.sourceforge.net/
---
tools/sdptool.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 6fb2e90..89a497a 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -513,14 +513,16 @@ static void sdp_data_printf(sdp_data_t *sdpdata, struct attrib_context *context,
*/
static void print_tree_attr_func(void *value, void *userData)
{
- sdp_data_t *sdpdata = NULL;
+ sdp_data_t *sdpdata = value;
uint16_t attrId;
struct service_context *service = (struct service_context *) userData;
struct attrib_context context;
struct attrib_def *attrDef = NULL;
int i;
- sdpdata = (sdp_data_t *)value;
+ if (!sdpdata)
+ return;
+
attrId = sdpdata->attrId;
/* Search amongst the generic attributes */
for (i = 0; i < attrib_max; i++)
@@ -549,10 +551,7 @@ static void print_tree_attr_func(void *value, void *userData)
context.attrib = attrDef;
context.member_index = 0;
/* Parse attribute members */
- if (sdpdata)
- sdp_data_printf(sdpdata, &context, 2);
- else
- printf(" NULL value\n");
+ sdp_data_printf(sdpdata, &context, 2);
/* Update service */
service->service = context.service;
}
@@ -723,6 +722,9 @@ static void print_raw_attr_func(void *value, void *userData)
struct attrib_def *def = NULL;
int i;
+ if (!data)
+ return;
+
/* Search amongst the generic attributes */
for (i = 0; i < attrib_max; i++)
if (attrib_names[i].num == data->attrId) {
@@ -735,10 +737,7 @@ static void print_raw_attr_func(void *value, void *userData)
else
printf("\tAttribute 0x%04x\n", data->attrId);
- if (data)
- print_raw_data(data, 2);
- else
- printf(" NULL value\n");
+ print_raw_data(data, 2);
}
static void print_raw_attr(sdp_record_t *rec)
--
1.7.1
next prev parent reply other threads:[~2010-06-05 10:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-05 10:14 Fixes issues reported by Smatch static checker Gustavo F. Padovan
2010-06-05 10:14 ` [PATCH 1/3] sbc: Fix redundant null check on calling free() Gustavo F. Padovan
2010-06-05 10:14 ` [PATCH 2/3] " Gustavo F. Padovan
2010-06-05 10:14 ` Gustavo F. Padovan [this message]
2010-06-08 6:27 ` [PATCH 3/3] sdptool: Fix 2 possible NULL dereference Johan Hedberg
2010-06-08 8:02 ` [PATCH 2/3] Fix redundant null check on calling free() Johan Hedberg
2010-06-08 6:21 ` [PATCH 1/3] sbc: " Johan Hedberg
2010-06-08 7:13 ` Marcel Holtmann
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=1275732870-15889-4-git-send-email-gustavo@padovan.org \
--to=gustavo@padovan.org \
--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;
as well as URLs for NNTP newsgroup(s).