Skip to contentSkip to conversation

net: aquantia: fix unintention integer overflow on left shift

PATCH Applied Colin King 3 participants 3 messages Oct 25, 2019 – Oct 29, 2019

Subsystems (5)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 net: aquantia: fix unintention integer overflow on left shift

From: Colin Ian King <[email protected]>

Shifting the integer value 1 is evaluated using 32-bit arithmetic and then used in an expression that expects a 64-bit value, so there is potentially an integer overflow. Fix this by using the BIT_ULL macro to perform the shift and avoid the overflow.

Addresses-Coverity: ("Unintentional integer overflow")

Fixes 04a1839950d9 ("net: aquantia: implement data PTP datapath")
---
 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +1 -1
index 232df785488c..3eb9d22f7402 100644
@@ -713,7 +713,7 @@ static int aq_ptp_poll(struct napi_struct *napi, int budget)
 	if (work_done < budget) {
 		napi_complete_done(napi, work_done);
 		aq_nic->aq_hw_ops->hw_irq_enable(aq_nic->aq_hw,
-					1 << aq_ptp->ptp_ring_param.vec_idx);
+					BIT_ULL(aq_ptp->ptp_ring_param.vec_idx));
 	}
 
 err_exit:
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

DQo+IEZyb206IENvbGluIElhbiBLaW5nIDxjb2xpbi5raW5nQGNhbm9uaWNhbC5jb20+DQo+IA0K PiBTaGlmdGluZyB0aGUgaW50ZWdlciB2YWx1ZSAxIGlzIGV2YWx1YXRlZCB1c2luZyAzMi1iaXQN Cj4gYXJpdGhtZXRpYyBhbmQgdGhlbiB1c2VkIGluIGFuIGV4cHJlc3Npb24gdGhhdCBleHBlY3Rz IGEgNjQtYml0DQo+IHZhbHVlLCBzbyB0aGVyZSBpcyBwb3RlbnRpYWxseSBhbiBpbnRlZ2VyIG92 ZXJmbG93LiBGaXggdGhpcw0KPiBieSB1c2luZyB0aGUgQklUX1VMTCBtYWNybyB0byBwZXJmb3Jt IHRoZSBzaGlmdCBhbmQgYXZvaWQgdGhlDQo+IG92ZXJmbG93Lg0KPiANCj4gQWRkcmVzc2VzLUNv dmVyaXR5OiAoIlVuaW50ZW50aW9uYWwgaW50ZWdlciBvdmVyZmxvdyIpDQo+IEZpeGVzOiAwNGEx ODM5OTUwZDkgKCJuZXQ6IGFxdWFudGlhOiBpbXBsZW1lbnQgZGF0YSBQVFAgZGF0YXBhdGgiKQ0K PiBTaWduZWQtb2ZmLWJ5OiBDb2xpbiBJYW4gS2luZyA8Y29saW4ua2luZ0BjYW5vbmljYWwuY29t Pg0KDQpSZXZpZXdlZC1ieTogSWdvciBSdXNza2lraCA8aXJ1c3NraWtoQG1hcnZlbGwuY29tPg0K DQo

maintainer Applied
#2 lore raw
In reply to Colin King

From: Colin King <[email protected]>
Date: Fri, 25 Oct 2019 12:58:11 +0100

Quoted 11 lines

From: Colin Ian King <[email protected]>

Shifting the integer value 1 is evaluated using 32-bit arithmetic and then used in an expression that expects a 64-bit value, so there is potentially an integer overflow. Fix this by using the BIT_ULL macro to perform the shift and avoid the overflow.

Addresses-Coverity: ("Unintentional integer overflow")

Fixes 04a1839950d9 ("net: aquantia: implement data PTP datapath")

Applied.