Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1656862

Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value

From Colin Ian King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value
Date 2017-06-03 18:40 +0200
Message-ID <tOkfL-Tr-3@gated-at.bofh.it> (permalink)
References <tNWds-2wl-13@gated-at.bofh.it> <tOjD3-q5-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 03/06/17 16:55, Andy Shevchenko wrote:
> On Fri, Jun 2, 2017 at 5:58 PM, Colin King <colin.king@canonical.com> wrote:
>> The current comparison of entry < 0 will never be true since entry is an
>> unsigned integer. Cast entry to an int to ensure -ve error return values
>> from the call to jumbo_frm are correctly being caught.
> 
>>         if (unlikely(is_jumbo) && likely(priv->synopsys_id <
>>                                          DWMAC_CORE_4_00)) {
>>                 entry = priv->hw->mode->jumbo_frm(tx_q, skb, csum_insertion);
>> -               if (unlikely(entry < 0))
>> +               if (unlikely((int)entry < 0))
> 
> It feels like a hiding some other issue.
> 

The alternative is:

		int rc = priv->hw->mode->jumbo_frm(tx_q, skb, csum_insertion);
		if (unlikely(rc < 0))
			goto dma_map_err;

		entry = rc;

however, that is effectively the same. The cast I'm using is a well used
idiom in the kernel, it used in almost a hundred similar cases.

git grep "< 0" | grep "(int)" | wc -l
95

Colin

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value Colin King <colin.king@canonical.com> - 2017-06-02 17:00 +0200
  Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly  checked for -ve value Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-03 18:00 +0200
    Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly  checked for -ve value Colin Ian King <colin.king@canonical.com> - 2017-06-03 18:40 +0200
      Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly  checked for -ve value Julia Lawall <julia.lawall@lip6.fr> - 2017-06-03 19:00 +0200
      Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly  checked for -ve value Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-03 19:20 +0200
  Re: [PATCH] net: stmmac: ensure jumbo_frm error return is  correctly checked for -ve value David Miller <davem@davemloft.net> - 2017-06-05 02:00 +0200

csiph-web