Skip to content

Commit 057cc8c

Browse files
hayesorzdavem330
authored andcommitted
r8152: fix accessing unset transport header
A warning is triggered by commit 66e4c8d ("net: warn if transport header was not set"). The warning is harmless, because the value from skb_transport_offset() is only used for skb_is_gso() is true or the skb->ip_summed is equal to CHECKSUM_PARTIAL. Fixes: 66e4c8d ("net: warn if transport header was not set") Signed-off-by: Hayes Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 67de8ac commit 057cc8c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/net/usb/r8152.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ static inline void rtl_rx_vlan_tag(struct rx_desc *desc, struct sk_buff *skb)
21562156
}
21572157

21582158
static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc,
2159-
struct sk_buff *skb, u32 len, u32 transport_offset)
2159+
struct sk_buff *skb, u32 len)
21602160
{
21612161
u32 mss = skb_shinfo(skb)->gso_size;
21622162
u32 opts1, opts2 = 0;
@@ -2167,6 +2167,8 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc,
21672167
opts1 = len | TX_FS | TX_LS;
21682168

21692169
if (mss) {
2170+
u32 transport_offset = (u32)skb_transport_offset(skb);
2171+
21702172
if (transport_offset > GTTCPHO_MAX) {
21712173
netif_warn(tp, tx_err, tp->netdev,
21722174
"Invalid transport offset 0x%x for TSO\n",
@@ -2197,6 +2199,7 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc,
21972199
opts1 |= transport_offset << GTTCPHO_SHIFT;
21982200
opts2 |= min(mss, MSS_MAX) << MSS_SHIFT;
21992201
} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
2202+
u32 transport_offset = (u32)skb_transport_offset(skb);
22002203
u8 ip_protocol;
22012204

22022205
if (transport_offset > TCPHO_MAX) {
@@ -2260,7 +2263,6 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
22602263
struct tx_desc *tx_desc;
22612264
struct sk_buff *skb;
22622265
unsigned int len;
2263-
u32 offset;
22642266

22652267
skb = __skb_dequeue(&skb_head);
22662268
if (!skb)
@@ -2276,9 +2278,7 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
22762278
tx_data = tx_agg_align(tx_data);
22772279
tx_desc = (struct tx_desc *)tx_data;
22782280

2279-
offset = (u32)skb_transport_offset(skb);
2280-
2281-
if (r8152_tx_csum(tp, tx_desc, skb, skb->len, offset)) {
2281+
if (r8152_tx_csum(tp, tx_desc, skb, skb->len)) {
22822282
r8152_csum_workaround(tp, skb, &skb_head);
22832283
continue;
22842284
}
@@ -2759,9 +2759,9 @@ rtl8152_features_check(struct sk_buff *skb, struct net_device *dev,
27592759
{
27602760
u32 mss = skb_shinfo(skb)->gso_size;
27612761
int max_offset = mss ? GTTCPHO_MAX : TCPHO_MAX;
2762-
int offset = skb_transport_offset(skb);
27632762

2764-
if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && offset > max_offset)
2763+
if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) &&
2764+
skb_transport_offset(skb) > max_offset)
27652765
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
27662766
else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz)
27672767
features &= ~NETIF_F_GSO_MASK;

0 commit comments

Comments
 (0)