Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp579952img; Thu, 21 Mar 2019 04:46:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcvYQpiqpJqrFMAdsM9qRbRtU0YDOKt2OJlGFdRcgOuQUiJCr/Rjf3xjXcDoYMYEyi8o6m X-Received: by 2002:a62:29c5:: with SMTP id p188mr2796360pfp.203.1553168783941; Thu, 21 Mar 2019 04:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553168783; cv=none; d=google.com; s=arc-20160816; b=rIFAAcqxzd8rjmZV1YuE5tEYMBjPK3Kpd/T+izIQT6QNtbMgdRVUD1RhqBZLVCw/1/ 1aq6irpPA8ZUjWnw6N+/3haeIB7REaVSnNMZChZn+Z9y1jlshMohGXVL5vGGtPXOUeO6 B/qoxHn5R9ENNL7xN03NwdNQ7TB/inKZ0poZuVv4wNVTQIECpWyaNoV1NobbvQCfraAU o1tjTsti3PfX4DyT9D8vN3tOOiQYIwYe0Jd2Z4ExZTsOLvi81e35M4wUmmXWmzEIcEdf +t875MYIcZUjw55B92CzGL9l2NYhOUDNDAkBe3O1hAWkiNUuOJlBEZriSRTX+FQkh/ti J5PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=BOa2Qq+enOx59Wyoou7QV6md7ZdaJ5A6Yx+Mn9ROcnc=; b=gqBBc/y3SaAG1pN8aYMj5HziKFtswLlrQrY3R/tIQT+w9GErpUCJRwaIc2KXHAYiQU ctxffeo1OhO/gCLILwmso5gxjRXLA3msHOL6pvWHiffIxxxekcfVk6OnZkfANFrDJl4Q BzerXxhYfKG6VwG7gqoi6LA+FWepJy/JCoGC/8Im+e3A0miBzip68/xcS5U5eDPp7Nxd QB9El2Of+3DFaiD31O5e8zgo71XURXmuCm19xhE/4mCqTBMHBH0ly/MFzS+Az9AE3CFE dcdZr1SNdIKlTqhWSvtYs+EO2jMcgU7gYnH5/8SptTvxrpD84mWGbSXTOvIE+En0VvYY 1iIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si4051496pfc.96.2019.03.21.04.46.05; Thu, 21 Mar 2019 04:46:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728093AbfCULpV (ORCPT + 99 others); Thu, 21 Mar 2019 07:45:21 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:36362 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727870AbfCULpU (ORCPT ); Thu, 21 Mar 2019 07:45:20 -0400 Received: by mail-qk1-f194.google.com with SMTP id k130so16077753qke.3; Thu, 21 Mar 2019 04:45:20 -0700 (PDT) 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; bh=BOa2Qq+enOx59Wyoou7QV6md7ZdaJ5A6Yx+Mn9ROcnc=; b=mQLNgNyr5/KSDV7J6s3LBXTtEQypgtXfCGYZfClWOQFZWGNbvY9vZu9/+9ns0I61ew HyYR1wQU4YUGzrOmHuG+MHlQHfQ8dc4zlHK/2z/+Q1+22E4R4R+0eOUDSlQJdCnW+Piv Sn4WFs4w5eaMarQIGIDv55xo9Tm91muI/4R0SncR8TG4Sd/DLDBRzo6/kZMA100bo82V Iy8k+FX3Y4ISdNWfnbNFnYntCEmfbn1EFfz9pZhgn1dZ4blh+EQ9JK80pOrstOC19wXx Bxie1R++/UMpHyzvzZMie5iKXA2xY8O6aWuoWtP9ZJDgqc3+ZwBMrWpiE8l9ov4yzarg g/nQ== X-Gm-Message-State: APjAAAXRVxkW/PgbGtXqCTY5jkCbbfPllsqacIhV4ERlVKPYFBFtE/pS pyZ7dpPBHgPwtP8YLeSJLqm5/Ce56oVwv2V2PMc= X-Received: by 2002:ae9:dec2:: with SMTP id s185mr2159398qkf.107.1553168719423; Thu, 21 Mar 2019 04:45:19 -0700 (PDT) MIME-Version: 1.0 References: <20190308001723.GA11197@archlinux-ryzen> <20190320190752.GA28744@archlinux-ryzen> In-Reply-To: From: Arnd Bergmann Date: Thu, 21 Mar 2019 12:45:02 +0100 Message-ID: Subject: Re: -Wsometimes-uninitialized Clang warning in net/tipc/node.c To: Nick Desaulniers Cc: Nathan Chancellor , Jon Maloy , Ying Xue , "David S. Miller" , tipc-discussion@lists.sourceforge.net, Networking , LKML , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 9:51 PM 'Nick Desaulniers' via Clang Built Linux wrote: > On Wed, Mar 20, 2019 at 12:07 PM Nathan Chancellor > wrote: > > The use in tipc_bearer_xmit() isn't even guaranteed to set the in/out > parameter, so even if the if is taken doesn't guarantee that maddr is > always initialized before calling tipc_bearer_xmit(). Right, it is only initialized in certain states. It was always initialized until commit 598411d70f85 ("tipc: make resetting of links non-atomic"), afterwards only if the link was not reset, and as of commit 73f646cec354 ("tipc: delay ESTABLISH state event when link is established") only if it's not 'establishing' or 'reset'. > At the minimum, we should initialize maddr to NULL. I think we'd > prefer to risk the possibility of a null pointer dereference to the > possibility of working with uninitialized memory. To be clear, both > are bad, but one is easier to spot/debug later than the other. I disagree with setting it to NULL, given that it is still an obviously incorrect value. We could add a if(maddr) check before calling tipc_bearer_xmit(), but I think it would be clearer to check skb_queue_empty(xmitq)) if that avoids the warning: diff --git a/net/tipc/node.c b/net/tipc/node.c index 2dc4919ab23c..147786795e48 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -844,7 +844,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) tipc_node_write_unlock(n); if (delete) tipc_mon_remove_peer(n->net, n->addr, old_bearer_id); - tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); + if (skb_queue_empty(xmitq)) + tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); tipc_sk_rcv(n->net, &le->inputq); } This duplicates the check inside of skb_queue_empty(), but I don't know if the compiler can see through the logic behind the inlined function calls. Arnd