Re: [PATCH] emulator: Fix possible NULL dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrei,

On Wed, Jan 08, 2014, Andrei Emeltchenko wrote:
> Move test dereference after it is checked for NULL.
> ---
>  tools/mgmt-tester.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
> index c518e47..325def1 100644
> --- a/tools/mgmt-tester.c
> +++ b/tools/mgmt-tester.c
> @@ -2646,6 +2646,14 @@ static void test_setup(const void *test_data)
>  	const struct generic_data *test = data->test_data;
>  	const uint16_t *cmd;
>  
> +	if (!test || !test->setup_settings) {
> +		if (data->test_setup)
> +			data->test_setup(data);
> +		else
> +			tester_setup_complete();
> +		return;
> +	}
> +
>  	if (test->pin) {
>  		struct bthost *bthost = hciemu_client_get_host(data->hciemu);
>  
> @@ -2655,14 +2663,6 @@ static void test_setup(const void *test_data)
>  				data, NULL);
>  	}
>  
> -	if (!test || !test->setup_settings) {
> -		if (data->test_setup)
> -			data->test_setup(data);
> -		else
> -			tester_setup_complete();
> -		return;
> -	}
> -
>  	for (cmd = test->setup_settings; *cmd; cmd++) {
>  		unsigned char simple_param[] = { 0x01 };
>  		unsigned char discov_param[] = { 0x01, 0x00, 0x00 };

This isn't quite right since setup_settings might be NULL while pin is
non-NULL. I pushed a simpler correct fix myself.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux