All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Atul Rai <a.rai@samsung.com>
Cc: linux-bluetooth@vger.kernel.org, sachin.dev@samsung.com
Subject: Re: [PATCH v2] tools/sdptool: Fix NULL pointer dereference
Date: Tue, 28 Jul 2015 10:40:56 +0300	[thread overview]
Message-ID: <20150728074056.GA2417@t440s.lan> (raw)
In-Reply-To: <1438068019-4094-1-git-send-email-a.rai@samsung.com>

Hi Atul,

On Tue, Jul 28, 2015, Atul Rai wrote:
> This patch fixes NULL pointer dereferences in case malloc fails
> and returns NULL.
> ---
>  tools/sdptool.c | 37 +++++++++++++++++++++++++++++++++----
>  1 file changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/sdptool.c b/tools/sdptool.c
> index 257964d..02e7f23 100644
> --- a/tools/sdptool.c
> +++ b/tools/sdptool.c
> @@ -902,9 +902,9 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri
>  	uint32_t range = 0x0000ffff;
>  	sdp_record_t *rec;
>  	sdp_data_t *pSequenceHolder = NULL;
> -	void **dtdArray;
> -	void **valueArray;
> -	void **allocArray;
> +	void **dtdArray = NULL;
> +	void **valueArray = NULL;
> +	void **allocArray = NULL;

This doesn't seem to be related to fixing missing malloc failure checks.
It's also unnecessary since all of these either way get unconditionally
assigned to before reading the values.

>  	/* Create arrays */
>  	dtdArray = (void **)malloc(argc * sizeof(void *));

While you're at it could you (in a separate patch) fix all of these
unnecessary typecasts of malloc return values?

Johan

  reply	other threads:[~2015-07-28  7:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28  7:20 [PATCH v2] tools/sdptool: Fix NULL pointer dereference Atul Rai
2015-07-28  7:40 ` Johan Hedberg [this message]
2015-07-28  7:57   ` Szymon Janc
2015-07-28  8:03     ` Johan Hedberg

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=20150728074056.GA2417@t440s.lan \
    --to=johan.hedberg@gmail.com \
    --cc=a.rai@samsung.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sachin.dev@samsung.com \
    /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.