Linux wireless drivers development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ajay.Kathat@microchip.com
Cc: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org,
	gregkh@linuxfoundation.org, johannes@sipsolutions.net,
	Adham.Abozaeid@microchip.com
Subject: Re: [PATCH 3/3] staging: wilc1000: refactor p2p action frames handling API's
Date: Tue, 11 Feb 2020 09:51:01 +0300	[thread overview]
Message-ID: <20200211065101.GC1778@kadam> (raw)
In-Reply-To: <20200211000652.4781-3-ajay.kathat@microchip.com>

On Mon, Feb 10, 2020 at 06:36:01PM +0000, Ajay.Kathat@microchip.com wrote:
> +	if (sta_ch == WILC_INVALID_CHANNEL)
> +		return;
>  
>  	while (index < len) {

This range checking was there in the original code, but it's not
correct.  index and len are in terms of bytes so we know that we can
read one byte from &buf[index] but we are reading a wilc_attr_entry
struct which is larger than a type.  The struct is actually flexibly
sized so this should be something like:

	while (index + sizeof(struct wilc_attr_entry) <= len) {
		e = (struct wilc_attr_entry *)&buf[index];
		if (index + sizeof(struct wilc_attr_entry) +
		    le16_to_cpu(e->attr_len) > len)
			break;

> -		if (buf[index] ==  CHANLIST_ATTR_ID)
> -			channel_list_attr_index = index;
> -		else if (buf[index] ==  OPERCHAN_ATTR_ID)
> -			op_channel_attr_index = index;
> -		index += buf[index + 1] + 3;
> +		e = (struct wilc_attr_entry *)&buf[index];
> +		if (e->attr_type == IEEE80211_P2P_ATTR_CHANNEL_LIST)
> +			ch_list_idx = index;
> +		else if (e->attr_type == IEEE80211_P2P_ATTR_OPER_CHANNEL)
> +			op_ch_idx = index;
> +		if (ch_list_idx && op_ch_idx)
> +			break;
> +		index += le16_to_cpu(e->attr_len) + sizeof(*e);
>  	}

regards,
dan carpenter

  reply	other threads:[~2020-02-11  6:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 18:35 [PATCH 1/3] staging: wilc1000: remove use of vendor specific IE for p2p handling Ajay.Kathat
2020-02-10 18:35 ` [PATCH 2/3] staging: wilc1000: directly fetch 'priv' handler from 'vif' instance Ajay.Kathat
2020-02-10 18:36 ` [PATCH 3/3] staging: wilc1000: refactor p2p action frames handling API's Ajay.Kathat
2020-02-11  6:51   ` Dan Carpenter [this message]
2020-02-11  6:58     ` Dan Carpenter
2020-02-11  9:28     ` Ajay.Kathat

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=20200211065101.GC1778@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Adham.Abozaeid@microchip.com \
    --cc=Ajay.Kathat@microchip.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@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