Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2084393ybm; Thu, 23 May 2019 11:07:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3h9kvT/drx+MbrhZxBFZZuRCCElSQxGN1L++FmeeMXGq877S9QCO0n3yFBYBo6k5pCWhD X-Received: by 2002:a17:902:7895:: with SMTP id q21mr95159278pll.73.1558634854344; Thu, 23 May 2019 11:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558634854; cv=none; d=google.com; s=arc-20160816; b=ljqpkQqLaYW/x09BjiJJ8LIaLRcKR9xe+lwbjbFXrYuLvfMzYwN4JK4jESJA5572Wf lT8MA5gl9jiJ8wbE7S/wAwz8KMF4zapCM9g57OwnAXPvPl90g15uQ+H7PykteRcR8rcx TEcFpIsC+nus3XTtO4Xe8TBMBNSTz10wkPSPcDHgIhYQRCdZf8iRm2vDAFm8meSw3/yu iJQ4p/JUalylX/PXFKav+o3F/dCksXPtqbmR22NamW8fdpUU5yzPlJIeG990ar3hleEz IIqRx+y+uq9ASDMUcImZXclZRKn5SdzAYDY+dGUMKrYg/VdwFYxfqf/6UT2TunraXSQn JpXw== 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:dkim-signature; bh=EGvOP3+NbBL/ooRQ1YmiUrB6TsdEmMLRkxxwgSQubSk=; b=k+lKBYFBpvu7ukfDXkzkhf4pWeqgkO7Hqm5C7337fjpr5o0DzDmyVNXJS/epVskQNp FM6tIG3xnZ+Vv3zxzSHMD/zo7Gd1IkbWCR7r95LeqVy3lhdaBbSSMaj7atH4Vm65CcKQ 52/YWxVIixjobRuftOeW2b41RFBeBpjvGn8nlNRfHpkQxjGHOboReDpX12XTJrOOTAXk OpREI/X/GHc2oglpzEJa6qPD2A9nlvYV2R7xLYZsgDb+Rd5iteJOo/8xtGP51xqz//R7 8uva7QD/np0YfnO4/OIiwHs1z2EJmuHcGmTQlLvwyI5gJTPN1oVE839E9QlZoky+GGWC ECog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=REmo1GJp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si296835pgl.77.2019.05.23.11.07.18; Thu, 23 May 2019 11:07:34 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=REmo1GJp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387395AbfEWSFl (ORCPT + 99 others); Thu, 23 May 2019 14:05:41 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36472 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731093AbfEWSFl (ORCPT ); Thu, 23 May 2019 14:05:41 -0400 Received: by mail-pf1-f195.google.com with SMTP id v80so3674299pfa.3 for ; Thu, 23 May 2019 11:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EGvOP3+NbBL/ooRQ1YmiUrB6TsdEmMLRkxxwgSQubSk=; b=REmo1GJpTDjXtFLbJ30rqVT5Q+QhHvY/DfM7u/X3ZhgyxYtXiLgOrIv9AqVBnIlpBk WHQ84d0bgZ2SYfsYN1b38aDnU8CIy4FS1jaMhJI+5vxzalfT5PkYcxuZMEIN+uWcx29/ 6BzJbP4Q3WYBbB50N2akYp1ooKcSWAiqS3YIWiDBcfx5jh4t+3GII9UUnkfsQxtPOtmL 0l5RgM/SPdp5wtgYZ5k+bgLrdsSwODkXemkZkG+51mpCSd3XMD5Gu9YLn9bPTnvMwgCY pzrU5vnCXi9w//aLp8uWF7SKdXpuSgMkhTiFl1aWHKIjnOumzAZY6rqd7FrGnwmUJVtk xMrA== 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=EGvOP3+NbBL/ooRQ1YmiUrB6TsdEmMLRkxxwgSQubSk=; b=QFDYtZFJLoFNXxiBA76KQj5CfRDNho24RZlCGSEASJhguRwGxcl2AeD0sDi1xYg7HQ RjqKT79LRGB/JKjSIk4uGdG0nIQNysfI173HLF+VOXDP8085Z02m/Yej/3q7wOvaT4Py JgYyUovIefpb/Y9N1u4+aj9rNTbTrv9bE9iaJut1W71I5cGY1r//QPSdq+7Wo6UDr8wp eRLN4WgXh95HvY3iBqmib0x6siDpL5aNqDzksMYle5xesCDDyHrat/5OF4O8WU8BAw0+ OjLpH9guib4Lp/9gSTn5hpzfDioGxIH1dmm2Ul1xDYOqkPp0aa+d0wFuBQg8aptTWCmf kV1Q== X-Gm-Message-State: APjAAAWgAlwX7kugsk5Jun2nUV3PMWm9hA6W1Mg7kCFJdmk+zH8iqqOH B1Rhi8qYnO3HrGj3fjSPndT1rGSNXgv9cI2eRQe61A== X-Received: by 2002:a63:a709:: with SMTP id d9mr31338141pgf.263.1558634739788; Thu, 23 May 2019 11:05:39 -0700 (PDT) MIME-Version: 1.0 References: <20190523161532.122421-1-natechancellor@gmail.com> In-Reply-To: <20190523161532.122421-1-natechancellor@gmail.com> From: Nick Desaulniers Date: Thu, 23 May 2019 11:05:28 -0700 Message-ID: Subject: Re: [PATCH] misc: sgi-xp: Properly initialize buf in xpc_get_rsvd_page_pa To: Nathan Chancellor Cc: Cliff Whickman , Robin Holt , Arnd Bergmann , Greg Kroah-Hartman , LKML , clang-built-linux , Stephen Hines , tony.luck@intel.com, rja@sgi.com, fenghua.yu@intel.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 Thu, May 23, 2019 at 9:20 AM Nathan Chancellor wrote: > > Clang warns: > > drivers/misc/sgi-xp/xpc_partition.c:73:14: warning: variable 'buf' is > uninitialized when used within its own initialization [-Wuninitialized] > void *buf = buf; > ~~~ ^~~ > 1 warning generated. > > Initialize it to NULL, which is more deterministic. > > Fixes: 279290294662 ("[IA64-SGI] cleanup the way XPC locates the reserved page") > Link: https://github.com/ClangBuiltLinux/linux/issues/466 > Suggested-by: Stephen Hines > Signed-off-by: Nathan Chancellor From https://github.com/ClangBuiltLinux/linux/issues/466#issuecomment-488781917 I tried to follow the rabbit hole, but eventually these void* get converted to u64's and passed along to function that I have no idea whether they handle the value `(u64)(void*)0` or not. Either way, they definitely don't handle uninitialized values/UB. I was going to cc Robin who's already cc'ed, but looks like this code was last touched 7-10 years ago. + Tony and Fenghua for ia64 since sn_partition_reserved_page_pa is defined in arch/ia64/include/asm/sn/sn_sal.h. In absence of consensus, I'll prefer NULL to uninitialized. Reviewed-by: Nick Desaulniers Thanks Nathan for following up on this. > --- > > Thanks Steve for the suggestion, don't know why that never crossed my > mind... > > I tried to follow buf all the way down in get_partition_rsvd_page to see > if there would be any dereferences and I didn't see any but I could > have easily missed something. > > drivers/misc/sgi-xp/xpc_partition.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c > index 3eba1c420cc0..782ce95d3f17 100644 > --- a/drivers/misc/sgi-xp/xpc_partition.c > +++ b/drivers/misc/sgi-xp/xpc_partition.c > @@ -70,7 +70,7 @@ xpc_get_rsvd_page_pa(int nasid) > unsigned long rp_pa = nasid; /* seed with nasid */ > size_t len = 0; > size_t buf_len = 0; > - void *buf = buf; > + void *buf = NULL; > void *buf_base = NULL; > enum xp_retval (*get_partition_rsvd_page_pa) > (void *, u64 *, unsigned long *, size_t *) = > -- > 2.22.0.rc1 > -- Thanks, ~Nick Desaulniers