public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joash Naidoo <joash.n09@gmail.com>
Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk,
	paskripkin@gmail.com, gregkh@linuxfoundation.org,
	linux-staging@lists.linux.dev
Subject: Re: [PATCH v2] staging: r8188eu: fix too many leading tabs
Date: Mon, 19 Sep 2022 15:08:48 +0300	[thread overview]
Message-ID: <Yyhb0MO5/bcBSvnu@kadam> (raw)
In-Reply-To: <20220919115111.2421-1-joash.n09@gmail.com>

On Mon, Sep 19, 2022 at 01:51:11PM +0200, Joash Naidoo wrote:
> Coding style fix. Fix too many leading tabs and line length.
> 
> Signed-off-by: Joash Naidoo <joash.n09@gmail.com>
> ---
> Changes in v2:
>     - Flip additional nested if conditions and don't reverse the last if statement
>     - Move declarations to start of function
>     - Separate converting __constant_htons to htons to another patch
> ---
>  drivers/staging/r8188eu/core/rtw_br_ext.c | 69 ++++++++++++-----------
>  1 file changed, 36 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c
> index bca20fe5c..2fec3bf39 100644
> --- a/drivers/staging/r8188eu/core/rtw_br_ext.c
> +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c
> @@ -601,42 +601,45 @@ struct dhcpMessage {
>  
>  void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb)
>  {
> +	__be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN));
                                       ^^^^^^^^^
Dereferencing skb before it has been NULL checked.  Also do we really
know how large the skb is?  We seem to making a lot of assumptions...


> +	struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN);
> +	struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2));
> +	/*  DHCP request */
> +	struct dhcpMessage *dhcph =
> +		(struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr));
> +	u32 cookie = be32_to_cpu((__be32)dhcph->cookie);
> +
>  	if (!skb)
            ^^^^
Checked too late.

>  		return;
>  

[ snip ]

> +	if (iph->protocol != IPPROTO_UDP) /*  UDP */
> +		return;
> +
> +	if ((udph->source != __constant_htons(CLIENT_PORT)) &&
> +	    (udph->dest != __constant_htons(SERVER_PORT)))

The && needs to be changed to ||.

> +		return;
> +

regards,
dan carpenter

      reply	other threads:[~2022-09-19 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 11:51 [PATCH v2] staging: r8188eu: fix too many leading tabs Joash Naidoo
2022-09-19 12:08 ` Dan Carpenter [this message]

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=Yyhb0MO5/bcBSvnu@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joash.n09@gmail.com \
    --cc=linux-staging@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    /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