Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp634025ybm; Wed, 27 May 2020 04:23:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu4bFOZgCLT9UB9ETSv2UT+Cx6MIQmyYBHUxwUhkciQlGP+uPXkMv56p7wUgEZDT8bHYvW X-Received: by 2002:a17:906:6043:: with SMTP id p3mr5503589ejj.29.1590578600969; Wed, 27 May 2020 04:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590578600; cv=none; d=google.com; s=arc-20160816; b=sDroWwwupVPawzDMdoBFaaIdtHbs6pgRPNaRPlFj53EysiRC2xCL40HCgiE5dT6sxJ LvcIbvTmYS9XgDSEByU7QzVV9ZgNcTLpQoeea3Q9EC2pgjIMO8DNamkXSmegCeL7HoFE YMKkFO53l9NW4ZVV1k3UJE4OeLYCIz2D0HndG4SW26o2RQ3UTJzG6RamS2SsW6sN1xMj /nReVbwJAgX9Pn09F2rAzrvo66LeUMs7McrrSfnWucgF0NGurMqgSKCqmYHeT5ZnHgSO HUBOZs1iRtUEvWF4gNtLWkCUZ0eCOn6PykagFUwBnWflAzTmkl9pWzxCdaekhTL7ir+f 17xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cpwITzrftWrJAY0LVaSeu6jYTmkJe1PVewzQjLawjdA=; b=VrwdAh68n9flUNG0r5IApwCr+Q6gW688dhO9uBleFLD6zmvbAhNNlsn2EDz28HAKyq F6OqY9OYqWd5lBFEnLlTV9PuHiiJL5X2/T34F8sd5LvdN9boncQmk6/RH86aBlqihnYH P4v4+lcZ57AKUV8rhbNAeCFUTC6lZ2JQYClqJi29up7w7lW7HNUH1YWwWBeLW9lWTbqV 1h4PGh5UfnwFFRw2ZAvHoSxS/3+I9RR6dUIwc6Of/kwMD5Sm8ye/LGjY+6ZozFba07xK thumXdT3pMparPAq+g9pKFHPL+4BXztNuYuCQ6Pa09xjzN+VKNa9FPZBUDMRZYzPd9jk V30Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=GxKyCH66; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx7si1756196ejb.526.2020.05.27.04.22.57; Wed, 27 May 2020 04:23:20 -0700 (PDT) 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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=GxKyCH66; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388267AbgE0Iq0 (ORCPT + 99 others); Wed, 27 May 2020 04:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388107AbgE0IqV (ORCPT ); Wed, 27 May 2020 04:46:21 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05859C03E97C for ; Wed, 27 May 2020 01:46:20 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id h10so25041793iob.10 for ; Wed, 27 May 2020 01:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=cpwITzrftWrJAY0LVaSeu6jYTmkJe1PVewzQjLawjdA=; b=GxKyCH668dBc5VipkdT8YFjPTCx5H6Ette6THzOjjs/DRDGNcXIMDQi5ZP5v3Sf9Oa mwVrP6RSqnYeL10DiHJM1SOkKIcn6brwgQRHX0b0oKqUeDUGj/rjNQW55Xq53NQfseRD vXhZTU3mB8ZA8VEHKczO26DPAktbj8hdettUmRE8i6vyRvcYoYFGvApZ8ukhZ5+bQK7D 9L8+5xCW38IQadhYPoyI/PQs166Rw+w8+8SWRYvSIyYFnkV+77MOB9qUtGq2ER6cdPV/ +/sr0UAOp1UfaGH7K0FiwaDoGqoJN+EI3wjFXv9n4Zv/oSigkjbvRq3z7WEgWAq+aZOX 0EsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=cpwITzrftWrJAY0LVaSeu6jYTmkJe1PVewzQjLawjdA=; b=GSKmSucjaMb+i2Hs1rA6UouLNgKVoM768bk3lEww/MRotDPQvIrUnjm3Gmc2BOPFDS /9TOPC/JybIMnaenvVLVJbfD+n5MCso1exwEfpgrSQn32KzsyKMLk95mxjeTDq2L0dRH KSL2QCcXCMbSzk3go69DRFLl6zRyxF8F7Ekn0TaIKSbtkfb73QgQSInPqDHrXtBLfc8b HCe2/EodiYwTAod6q7wfsvwxMyfZjuNxRWjKm6YqPVOQ7RrIFnYmFyatwV8u8725xD6V BHLki8PLXZnlvbxlDzrA6zK4bRybTM4v30S5Oohzs8hzQynbjwk4s/w1LIeRSJYX6Xy+ Mpqg== X-Gm-Message-State: AOAM532SG9JcbBk8QFqD3GWt/ORBxQFnh5DyQiRGDW/Z7J3eD7YL9bnO 8WzMGYbCn6qp0JYQyn6g+Wp7QETLBrCGK8Uo6cdamA== X-Received: by 2002:a02:3e06:: with SMTP id s6mr4481666jas.57.1590569179357; Wed, 27 May 2020 01:46:19 -0700 (PDT) MIME-Version: 1.0 References: <20200522120700.838-1-brgl@bgdev.pl> <20200522120700.838-7-brgl@bgdev.pl> <20200527073150.GA3384158@ubuntu-s3-xlarge-x86> In-Reply-To: <20200527073150.GA3384158@ubuntu-s3-xlarge-x86> From: Bartosz Golaszewski Date: Wed, 27 May 2020 10:46:08 +0200 Message-ID: Subject: Re: [PATCH v5 06/11] net: ethernet: mtk-star-emac: new driver To: Nathan Chancellor Cc: Rob Herring , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer , devicetree , Linux Kernel Mailing List , netdev , Linux ARM , "moderated list:ARM/Mediatek SoC..." , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =C5=9Br., 27 maj 2020 o 09:31 Nathan Chancellor napisa=C5=82(a): > > On Fri, May 22, 2020 at 02:06:55PM +0200, Bartosz Golaszewski wrote: > > > > > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/ne= t/ethernet/mediatek/mtk_star_emac.c > > new file mode 100644 > > index 000000000000..789c77af501f > > --- /dev/null > > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > > @@ -0,0 +1,1678 @@ > > > > I've searched netdev and I cannot find any reports from others but this > function introduces a clang warning: > > drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:6: warning: variable '= new_dma_addr' is used uninitialized whenever 'if' condition is true [-Wsome= times-uninitialized] > if (!new_skb) { > ^~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialize= d use occurs here > desc_data.dma_addr =3D new_dma_addr; > ^~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1296:2: note: remove the 'i= f' if its condition is always false > if (!new_skb) { > ^~~~~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable '= new_dma_addr' is used uninitialized whenever 'if' condition is true [-Wsome= times-uninitialized] > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialize= d use occurs here > desc_data.dma_addr =3D new_dma_addr; > ^~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:2: note: remove the 'i= f' if its condition is always false > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: warning: variable '= new_dma_addr' is used uninitialized whenever '||' condition is true [-Wsome= times-uninitialized] > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1321:23: note: uninitialize= d use occurs here > desc_data.dma_addr =3D new_dma_addr; > ^~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1285:6: note: remove the '|= |' if its condition is always false > if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/mediatek/mtk_star_emac.c:1274:25: note: initialize t= he variable 'new_dma_addr' to silence this warning > dma_addr_t new_dma_addr; > ^ > =3D 0 > 3 warnings generated. > > > +static int mtk_star_receive_packet(struct mtk_star_priv *priv) > > +{ > > + struct mtk_star_ring *ring =3D &priv->rx_ring; > > + struct device *dev =3D mtk_star_get_dev(priv); > > + struct mtk_star_ring_desc_data desc_data; > > + struct net_device *ndev =3D priv->ndev; > > + struct sk_buff *curr_skb, *new_skb; > > + dma_addr_t new_dma_addr; > > Uninitialized here > > > + int ret; > > + > > + spin_lock(&priv->lock); > > + ret =3D mtk_star_ring_pop_tail(ring, &desc_data); > > + spin_unlock(&priv->lock); > > + if (ret) > > + return -1; > > + > > + curr_skb =3D desc_data.skb; > > + > > + if ((desc_data.flags & MTK_STAR_DESC_BIT_RX_CRCE) || > > + (desc_data.flags & MTK_STAR_DESC_BIT_RX_OSIZE)) { > > + /* Error packet -> drop and reuse skb. */ > > + new_skb =3D curr_skb; > > + goto push_new_skb; > > this goto > > > + } > > + > > + /* Prepare new skb before receiving the current one. Reuse the cu= rrent > > + * skb if we fail at any point. > > + */ > > + new_skb =3D mtk_star_alloc_skb(ndev); > > + if (!new_skb) { > > + ndev->stats.rx_dropped++; > > + new_skb =3D curr_skb; > > + goto push_new_skb; > > and this goto > > > + } > > + > > + new_dma_addr =3D mtk_star_dma_map_rx(priv, new_skb); > > + if (dma_mapping_error(dev, new_dma_addr)) { > > + ndev->stats.rx_dropped++; > > + dev_kfree_skb(new_skb); > > + new_skb =3D curr_skb; > > + netdev_err(ndev, "DMA mapping error of RX descriptor\n"); > > + goto push_new_skb; > > + } > > + > > + /* We can't fail anymore at this point: it's safe to unmap the sk= b. */ > > + mtk_star_dma_unmap_rx(priv, &desc_data); > > + > > + skb_put(desc_data.skb, desc_data.len); > > + desc_data.skb->ip_summed =3D CHECKSUM_NONE; > > + desc_data.skb->protocol =3D eth_type_trans(desc_data.skb, ndev); > > + desc_data.skb->dev =3D ndev; > > + netif_receive_skb(desc_data.skb); > > + > > +push_new_skb: > > + desc_data.dma_addr =3D new_dma_addr; > > assign it uninitialized here. > > > + desc_data.len =3D skb_tailroom(new_skb); > > + desc_data.skb =3D new_skb; > > + > > + spin_lock(&priv->lock); > > + mtk_star_ring_push_head_rx(ring, &desc_data); > > + spin_unlock(&priv->lock); > > + > > + return 0; > > +} > > I don't know if there should be a new label that excludes that > assignment for those particular gotos or if new_dma_addr should > be initialized to something at the top. Please take a look at > addressing this when you get a chance. > > Cheers, > Nathan Hi Nathan, Thanks for reporting this! I have a fix ready and will send it shortly. Bartosz