Message ID | 20180826231332.2491-6-erosca@de.adit-jv.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ey1o5cGH"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41z9w45wNtz9s1c for <incoming@patchwork.ozlabs.org>; Mon, 27 Aug 2018 09:19:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 87127C21E3A; Sun, 26 Aug 2018 23:16:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3F690C21D8E; Sun, 26 Aug 2018 23:16:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B6AE8C21D56; Sun, 26 Aug 2018 23:16:10 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id C3201C21E18 for <u-boot@lists.denx.de>; Sun, 26 Aug 2018 23:16:08 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id u12-v6so10597960wrr.4 for <u-boot@lists.denx.de>; Sun, 26 Aug 2018 16:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dX2nLVR3tsGUOEJ/oPnGWgI2JKCv6fUcgXOlvnE2+I0=; b=Ey1o5cGHIc3Qqlp5OJp1Fgv/JBzrnjp6ESRfOwtU2S2/VEcPo24EIDldNXalZo7Q7O LiQvF/CAq347/udilhlxQIKzDpGkkBIuS5MMOcGVsEuhz6SrdhqTphl8R/0rJrgzBcw8 GxDBueN5Lwt6OXuv+QkxzHPlfDPshAzJwPBKrcS2QEBZNrnJBpZszbpoBldvKkQhcxH0 BFtRwJFqs+4I9rlvXG7aBAa+h+PjSa2bgb+/x6VhUCL0oOBl3chZEGwQG11+aWjaNOqg 8q7nxNA33uhf8t0PZMbuJPtsHI3Pc/7D6cwaHuQo1TIJRqpPwTdkHdiOtvtChDSba1zo KhZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dX2nLVR3tsGUOEJ/oPnGWgI2JKCv6fUcgXOlvnE2+I0=; b=t525254zpDZ0K6zz8/ag/lr3IKUqI74YV3NGHF/2zeFVxa1tRP4o/Ox904KriUJvKh Gnn0nUIaQlFCoSNtYxykUOngzqHl17c1DZ7X9KyFvPmK4ACz3d+fAY24nFwenBrlJ06Q E8bkQ3LRXWt3IN6WudbJER1SpHKd9aHGgaLIr4mMHTggGwO6RjjW7FjzTZyeXUkvaisP VJ+m9dOoDZXgxNBsjPeVx76gRGc0vHQXD0uYK6JgPzouAcf4bhjz481M8McXer+QphWZ LZWiZWZlSrAM9nEwgTy0euzb8Mk0pPtPKIUCicgQCzl4fPnxzaxr//QNSN+AmYmLrY49 Fvsw== X-Gm-Message-State: APzg51CXEE6POBzG2Vs93Dsdk+oo53PtfggMBHMvkOjBtwDys2PEJC9s uxgbRNZwz6VzN2wc0Tq8fws= X-Google-Smtp-Source: ANB0VdaDUCjKiV/SREHX0e00w8DkuifFJ6ReQlgdpYqbL3ux897jrWuTlYbfrDE1HD9WYg4HmGYspw== X-Received: by 2002:adf:e711:: with SMTP id c17-v6mr6632830wrm.143.1535325368436; Sun, 26 Aug 2018 16:16:08 -0700 (PDT) Received: from localhost.localdomain (ipb218f467.dynamic.kabel-deutschland.de. [178.24.244.103]) by smtp.gmail.com with ESMTPSA id e141-v6sm10828362wmd.32.2018.08.26.16.16.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Aug 2018 16:16:07 -0700 (PDT) From: Eugeniu Rosca <roscaeugeniu@gmail.com> X-Google-Original-From: Eugeniu Rosca <erosca@de.adit-jv.com> To: Tom Rini <trini@konsulko.com>, u-boot@lists.denx.de Date: Mon, 27 Aug 2018 01:13:23 +0200 Message-Id: <20180826231332.2491-6-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180826231332.2491-1-erosca@de.adit-jv.com> References: <20180826231332.2491-1-erosca@de.adit-jv.com> Cc: Eugeniu Rosca <erosca@de.adit-jv.com>, Eugeniu Rosca <roscaeugeniu@gmail.com>, Joe Hershberger <joe.hershberger@ni.com>, Stefan Roese <sr@denx.de> Subject: [U-Boot] [PATCH v2 05/13] net: phy: Fix signed shift overflow X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <http://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> |
Series |
Import Undefined Behavior Sanitizer
|
expand
|
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index e837eb7688cc..0a8df72a495f 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -719,13 +719,13 @@ static struct phy_device *search_for_existing_phy(struct mii_dev *bus, { /* If we have one, return the existing device, with new interface */ while (phy_mask) { - int addr = ffs(phy_mask) - 1; + unsigned int addr = ffs(phy_mask) - 1; if (bus->phymap[addr]) { bus->phymap[addr]->interface = interface; return bus->phymap[addr]; } - phy_mask &= ~(1 << addr); + phy_mask &= ~(1UL << addr); } return NULL; }
Booting R-Car Gen3 arm64 U-Boot with CONFIG_UBSAN=y results in: ===================================================================== UBSAN: Undefined behaviour in drivers/net/phy/phy.c:728:19 left shift of 1 by 31 places cannot be represented in type 'int' ===================================================================== Fix it by appending the UL suffix to the numeric literal. While at it, convert the type of "addr" variable from signed to unsigned, to protect against shifting the numeric literal by a negative value (which would lead to yet another undefined behavior). Fixes: 1adb406b0141 ("phy: add phy_find_by_mask/phy_connect_dev") Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> --- Changes in v2: - Shorten the summary line. Rephrase/rewrap the description. --- drivers/net/phy/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)