public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Alexander Vorwerk <alexander.vorwerk@stud.uni-goettingen.de>
Cc: <edumazet@google.com>, <davem@davemloft.net>,
	<yoshfuji@linux-ipv6.org>, <dsahern@kernel.org>,
	<kuba@kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: ipv4: tcp.c: fix an assignment in an if condition
Date: Sat, 12 Mar 2022 09:19:36 -0800	[thread overview]
Message-ID: <20220312091936.1f8c9289@hermes.local> (raw)
In-Reply-To: <20220312162744.32318-1-alexander.vorwerk@stud.uni-goettingen.de>

On Sat, 12 Mar 2022 17:27:44 +0100
Alexander Vorwerk <alexander.vorwerk@stud.uni-goettingen.de> wrote:

> reported by checkpatch.pl
> 
> Signed-off-by: Alexander Vorwerk <alexander.vorwerk@stud.uni-goettingen.de>
> ---
>  net/ipv4/tcp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 28ff2a820f7c..7fa6e7e6ea80 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -959,10 +959,10 @@ static struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags,
>  	struct sk_buff *skb = tcp_write_queue_tail(sk);
>  	struct tcp_sock *tp = tcp_sk(sk);
>  	bool can_coalesce;
> -	int copy, i;
> +	int copy = size_goal - skb->len;
> +	int i;
>  
> -	if (!skb || (copy = size_goal - skb->len) <= 0 ||
> -	    !tcp_skb_can_collapse_to(skb)) {
> +	if (!skb || copy <= 0 || !tcp_skb_can_collapse_to(skb)) {
>  new_segment:
>  		if (!sk_stream_memory_free(sk))
>  			return NULL;

Your new code will crash if skb is NULL.

      parent reply	other threads:[~2022-03-12 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12 16:27 [PATCH] net: ipv4: tcp.c: fix an assignment in an if condition Alexander Vorwerk
2022-03-12 17:19 ` Al Viro
2022-03-12 17:19 ` Stephen Hemminger [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=20220312091936.1f8c9289@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=alexander.vorwerk@stud.uni-goettingen.de \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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