From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91F501684A3; Tue, 15 Oct 2024 11:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728992199; cv=none; b=X4+IB30SUxHkAQu9nxx2tQ1XSa9//miEIDzdu+/TJlqCr2R+MrLirnqEcPeUoL4nYHPIglObj6h5nFU0qgc4rdqvWvIUvyv4IqpCU+RGQDlo5XXHHLbaPb7dRrwH4yOnnFBHR0wGjcnpCwAx+Mf6yXzrt7l8k2mkJUuwl/AXatY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728992199; c=relaxed/simple; bh=9Jl/kchKi7IXobms8EyLJTiMVL5C1aJ856IVCwH4hoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ECiZ5c/ML5oTYcZkhRdnCmQZMXUChr+ivLZWGT18nUdlj9kubLUviag377DT2UE+1AklxkQJ2+KrqAKdB6dkJwG4Nm2IOVVqIVp/d3QxqDZp+ayIVJFjzV5UYsRlT5EzstV9BDe1lYmBCwjeacxJdvDeeN2OcSgJIEvXpGhoenI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p2sy1vS/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="p2sy1vS/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BE78C4CEC6; Tue, 15 Oct 2024 11:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728992199; bh=9Jl/kchKi7IXobms8EyLJTiMVL5C1aJ856IVCwH4hoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2sy1vS/qZFLg07noMnJurNu+Ik/B+q9iBn02Yr971uDE0pf822rHRNwEw6EAw/Wn pCNnACJS/1hUBxflBXHRkVsObsq3+lXLqdlm/LbmUuDob3UT/YZy+sDF/d+Q/Hl4ue obhBfurgyT58EkblzetJPduFjLxKo+Fb+yNllIxw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Moon Yeounsu , Christophe JAILLET , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 016/691] net: ethernet: use ip_hdrlen() instead of bit shift Date: Tue, 15 Oct 2024 13:19:24 +0200 Message-ID: <20241015112440.979102774@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015112440.309539031@linuxfoundation.org> References: <20241015112440.309539031@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moon Yeounsu [ Upstream commit 9a039eeb71a42c8b13408a1976e300f3898e1be0 ] `ip_hdr(skb)->ihl << 2` is the same as `ip_hdrlen(skb)` Therefore, we should use a well-defined function not a bit shift to find the header length. It also compresses two lines to a single line. Signed-off-by: Moon Yeounsu Reviewed-by: Christophe JAILLET Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/jme.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 1bdc4f23e1e5..06890993662a 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -945,15 +945,13 @@ jme_udpsum(struct sk_buff *skb) if (skb->protocol != htons(ETH_P_IP)) return csum; skb_set_network_header(skb, ETH_HLEN); - if ((ip_hdr(skb)->protocol != IPPROTO_UDP) || - (skb->len < (ETH_HLEN + - (ip_hdr(skb)->ihl << 2) + - sizeof(struct udphdr)))) { + + if (ip_hdr(skb)->protocol != IPPROTO_UDP || + skb->len < (ETH_HLEN + ip_hdrlen(skb) + sizeof(struct udphdr))) { skb_reset_network_header(skb); return csum; } - skb_set_transport_header(skb, - ETH_HLEN + (ip_hdr(skb)->ihl << 2)); + skb_set_transport_header(skb, ETH_HLEN + ip_hdrlen(skb)); csum = udp_hdr(skb)->check; skb_reset_transport_header(skb); skb_reset_network_header(skb); -- 2.43.0