Linux-WPAN Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net-next] ieee802154: ca8210: remove a dead branch
@ 2018-12-10 11:34 YueHaibing
  2018-12-10 20:04 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2018-12-10 11:34 UTC (permalink / raw)
  To: davem, h.morris, alex.aring, stefan
  Cc: linux-kernel, netdev, linux-wpan, YueHaibing

Fix follwing gcc warning:

drivers/net/ieee802154/ca8210.c:730:10: warning:
 comparison is always false due to limited range of data type [-Wtype-limits]

the variable 'len' is of type u8 and cannot greater than
CA8210_SPI_BUF_SIZE , which is 256.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ieee802154/ca8210.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 0ff5a40..0fe204f 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -727,14 +727,6 @@ static void ca8210_rx_done(struct cas_control *cas_ctl)
 
 	buf = cas_ctl->tx_in_buf;
 	len = buf[1] + 2;
-	if (len > CA8210_SPI_BUF_SIZE) {
-		dev_crit(
-			&priv->spi->dev,
-			"Received packet len (%d) erroneously long\n",
-			len
-		);
-		goto finish;
-	}
 
 	if (buf[0] & SPI_SYN) {
 		if (priv->sync_command_response) {
-- 
2.7.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ieee802154: ca8210: remove a dead branch
  2018-12-10 11:34 [PATCH net-next] ieee802154: ca8210: remove a dead branch YueHaibing
@ 2018-12-10 20:04 ` David Miller
  2018-12-11  1:51   ` YueHaibing
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-12-10 20:04 UTC (permalink / raw)
  To: yuehaibing; +Cc: h.morris, alex.aring, stefan, linux-kernel, netdev, linux-wpan

From: YueHaibing <yuehaibing@huawei.com>
Date: Mon, 10 Dec 2018 19:34:43 +0800

> Fix follwing gcc warning:
> 
> drivers/net/ieee802154/ca8210.c:730:10: warning:
>  comparison is always false due to limited range of data type [-Wtype-limits]
> 
> the variable 'len' is of type u8 and cannot greater than
> CA8210_SPI_BUF_SIZE , which is 256.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Then bug is the variable type here.

We are reading a u8 from buf[], then adding 2, which can overflow.

'len' should be an unsigned int or similar.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] ieee802154: ca8210: remove a dead branch
  2018-12-10 20:04 ` David Miller
@ 2018-12-11  1:51   ` YueHaibing
  0 siblings, 0 replies; 3+ messages in thread
From: YueHaibing @ 2018-12-11  1:51 UTC (permalink / raw)
  To: David Miller
  Cc: h.morris, alex.aring, stefan, linux-kernel, netdev, linux-wpan

On 2018/12/11 4:04, David Miller wrote:
> From: YueHaibing <yuehaibing@huawei.com>
> Date: Mon, 10 Dec 2018 19:34:43 +0800
> 
>> Fix follwing gcc warning:
>>
>> drivers/net/ieee802154/ca8210.c:730:10: warning:
>>  comparison is always false due to limited range of data type [-Wtype-limits]
>>
>> the variable 'len' is of type u8 and cannot greater than
>> CA8210_SPI_BUF_SIZE , which is 256.
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Then bug is the variable type here.
> 
> We are reading a u8 from buf[], then adding 2, which can overflow.
> 
> 'len' should be an unsigned int or similar.

Oh, Yes, will do it in v2.

> 
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 11:34 [PATCH net-next] ieee802154: ca8210: remove a dead branch YueHaibing
2018-12-10 20:04 ` David Miller
2018-12-11  1:51   ` YueHaibing

Linux-WPAN Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-wpan/0 linux-wpan/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-wpan linux-wpan/ https://lore.kernel.org/linux-wpan \
		linux-wpan@vger.kernel.org
	public-inbox-index linux-wpan

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-wpan


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git