Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp107591ybh; Tue, 10 Mar 2020 20:30:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtngodYiHcBebwkRqYb+19IkhZ5NGQ/iYB1hpc6w6oVLVuZk+sNlSeNBlq8G0j5TnX61oXe X-Received: by 2002:a9d:67c7:: with SMTP id c7mr757011otn.85.1583897457558; Tue, 10 Mar 2020 20:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583897457; cv=none; d=google.com; s=arc-20160816; b=NYhgwwjut05CA+V3M21Tx222u/nxL3JAjgWvjc47SWBRRJhUYXPzldGoMf8R8AnByW XK7euDPlR9ApBLsOBLeNXIGEMKZSUmPx4NQ/3FxovgcuLO3hoQqDUXIpvlkhcxfH9tIl WBG2U3Seu1xUtK+9QrLmR65CPTRmoZeJyUi/bAKEOsS7tC0MefP2by3m6vLV/mK/JLke uID2wjDr7IjbJOxSa4rEH+JTNIeKdjHRvIDONDIZb620GiqI1StN0R7RZBPUJnvde57f zPpJCuTdK0IYbDLIEzIfqJQ6ZjLP9bGLaBE92cFOsCrRspq6yKp6u2ie3LKPJM1CmdP/ kxlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FsqjcSVeKkS8hG7pZcOZTW0GjSe7/Xeo3rMyKKcmYV0=; b=BON9P7SMBXcKWmS6zqErHAnqRyZpg1ue5tCXDsGxPTMOHPiAmswKPVbZCZ9LEZ/O5T siWieiuJKceU6PQrkiNQNvcXWl9qWXNW62sVFwM4FXPZ4qpjB/p02E5TYQiCZGpwiwwb ypZpIWgSKl1r0d5gVwXlSfv2WLDhnJAQCuafrYrsMu0VNihiS2gMFUIf5B+jyQZpiyuZ fo0l9ZKCvOQOltUYwDTTvgJyWQfMMU1DYUAcUT3f/J+78cCFnvS8tx73Yyce8K7O0ZYD ACfZRtJGKqWvNYdTWc9fv5wffgXYYMXBNNBwKVYCu1uvQVQWoBTa7Jb/6hYRSYmTFQSJ 0NQQ== 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 d21si380272otq.72.2020.03.10.20.30.45; Tue, 10 Mar 2020 20:30:57 -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 S1727986AbgCKDaa (ORCPT + 99 others); Tue, 10 Mar 2020 23:30:30 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37115 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbgCKDa3 (ORCPT ); Tue, 10 Mar 2020 23:30:29 -0400 Received: from ip5f5bf7ec.dynamic.kabel-deutschland.de ([95.91.247.236] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jBs4b-0007j0-Tj; Wed, 11 Mar 2020 03:30:22 +0000 Date: Wed, 11 Mar 2020 04:30:21 +0100 From: Christian Brauner To: John Hubbard Cc: Stephen Rothwell , Linux Next , LKML Subject: Re: [PATCH] pid: fix uninitialized retval in alloc_pid() Message-ID: <20200311033021.qm26c6cltfndlx3c@wittgenstein> References: <20200311032153.431492-1-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200311032153.431492-1-jhubbard@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 10, 2020 at 08:21:53PM -0700, John Hubbard wrote: > Commit 8deb24dcb89cb ("pid: make ENOMEM return value more obvious") > left the return value uninitialized in one error case. The justification > for the above commit included a statement that retval is "initialized on > ever[y] failure path in the loop". However, that is not quite good > enough because there is an earlier case that is before the loop. And > also, it's more maintenance and merge-safe to initialize it once at the > top, as evidenced by this build warning that we now have. > > Therefore, restore the top-level initialization of retval. > > Also move the descriptive comment up, and remove the now-redundant > later initialization of retval. > > Fixes: 8deb24dcb89cb ("pid: make ENOMEM return value more obvious") > Cc: Christian Brauner > Signed-off-by: John Hubbard Thanks. I already have a fixed-up version in my tree after Stephen reported it earlier today: https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=10dab84caf400f2f5f8b010ebb0c7c4272ec5093 (Fwiw, we can't just move the it back up. It needs to be set after the loop too because it can be set to EPERM before. See https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=b26ebfe12f34f372cf041c6f801fa49c3fb382c5 for the motiviation for the comment.) Christian