Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp6049pxb; Tue, 10 Nov 2020 17:51:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxVrrlknf604ywNPJups5tVpR7DzxyuUv90OmMMstMvQaBEMbTOkGa8fceu/D740QY9plv X-Received: by 2002:a17:906:402:: with SMTP id d2mr21685156eja.165.1605059502761; Tue, 10 Nov 2020 17:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605059502; cv=none; d=google.com; s=arc-20160816; b=SIfWlS8ejFbwaC3ogfv8iYwA700SGQgmhyYTEqVp3Sr8l1T7K9n5h/Ft4qwI+DNnws 7wY6vOjHcw5RqI1s6pRHbiESe9zjLBejJvJJ5h9uWIAHdZh3h/0t2aq3+BlEDUS4BZjb nOmEs8ahYPs0X9FTyjuv+pqd4S5uhcw8dqApdcBV/e/tG1GmES39eisEKN++tBjRXxHl YXw0qaM5PL80eq5QI8LZQSIIwY1SZlPx6hYawbNkjhwK7nh64JYVGdkI+2zo5gE90jmA jfpZJ9NDV/HqCXDx8S1sOJEeZS5wXuEtoy5ZI5OPM9dyc/MsJJjUYwAzyj/MQGr7OJZI w67Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=EuIAlckA1zj1hAN+an7Ly2Rrb4Lzc6ycm1wDDo0JGSo=; b=WK7N0obKL3SE2mEvonbUyjtZPtOTVva48Jg2jdXw7AKDFwbtt5OLceX5uORxckKea6 QBw59ZZABexM/woeaF3KEcwBBnOqXX1dHBHeOEtX1P18UrWUvp47v639WNKqhv9FCcg+ Bj4oFvIOrF1kzv/VKsywai3AXwxVF82YLLJWab3PF2xzqUCTsSktQb1CzLclj1AEuO0n QQGm1BCgkgszgQIh6ZhBE6xF+WACBQh53XbgYLmZoe2axvHlrW4CPtCtJkfIRtnv0OBP vEaBpwWtvcJ5WMrS7wO2GLWU44ExiyYnA0m6ashjtsIthkYX4Tb/p586gyZqNasmtWrK crhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q+jPt3Nt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 89si412475edc.413.2020.11.10.17.51.18; Tue, 10 Nov 2020 17:51:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q+jPt3Nt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732553AbgKKBse (ORCPT + 99 others); Tue, 10 Nov 2020 20:48:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:37098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731805AbgKKBse (ORCPT ); Tue, 10 Nov 2020 20:48:34 -0500 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27A87216C4; Wed, 11 Nov 2020 01:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605059313; bh=8ZoXFi19cRFxurUpEO5osza2tLaJVaBLs/a+W0ovF1c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Q+jPt3Nt8m8DXdJcqcPyssEU7Br3tkPgCzb5XIORN1OLhAFgMJknyUmyBrzhIZdjN kcX/8hLGdtUMkj0WJFs99Qe0fAbmTAf7vmho8iFR/BVq6qHO28n9Ez/qgFnwuS6j6k MfSackoKWIR0fOla91sG3lNObegpHFomKRKzTEgM= Date: Tue, 10 Nov 2020 17:48:32 -0800 From: Jakub Kicinski To: Kurt Kanzenbach , Colin King Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] net: dsa: fix unintended sign extension on a u16 left shift Message-ID: <20201110174832.437b4951@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <87y2jar76v.fsf@kurt> References: <20201109124008.2079873-1-colin.king@canonical.com> <87y2jar76v.fsf@kurt> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 09 Nov 2020 14:27:52 +0100 Kurt Kanzenbach wrote: > On Mon Nov 09 2020, Colin King wrote: > > From: Colin Ian King > > > > The left shift of u16 variable high is promoted to the type int and > > then sign extended to a 64 bit u64 value. If the top bit of high is > > set then the upper 32 bits of the result end up being set by the > > sign extension. Fix this by explicitly casting the value in high to > > a u64 before left shifting by 16 places. > > > > Also, remove the initialisation of variable value to 0 at the start > > of each loop iteration as the value is never read and hence the > > assignment it is redundant. > > > > Addresses-Coverity: ("Unintended sign extension") > > Fixes: e4b27ebc780f ("net: dsa: Add DSA driver for Hirschmann Hellcreek switches") > > Signed-off-by: Colin Ian King > > Reviewed-by: Kurt Kanzenbach Applied, thanks!