Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4814148iob; Mon, 9 May 2022 02:11:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWjq6Y1GZJ3bsX3qkSWNzD0LFgdpaIBIPNV00AjgAJEhP3IAWWcFJRFoq0+mbjt48kCxnM X-Received: by 2002:a17:902:e549:b0:15e:aa63:6fb8 with SMTP id n9-20020a170902e54900b0015eaa636fb8mr15512161plf.20.1652087459855; Mon, 09 May 2022 02:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652087459; cv=none; d=google.com; s=arc-20160816; b=egMTGZf6FZQ/WvauzXYbnIzAeF+WG9CEiY1rqZntSch0PNfPtcquRs7HsH9qMdlUXG vZ2S/N43BUkV8qqIvTuNlueL9n49D5nU3gT+1dY9UR8cJZEBfwnnOGBhuj2GmGzy/LRB Ysxr4xN6sEoB/Q19ckdsdUMuN6ehDQ6oscihIlJsrw5Q+Vj3MSgihcY9uZ/YmllX1Qmz 03pqFD88sJv4qw0VCe3gzygAjO+t1DpfLINlfwbM4JXs5k8xLBpLrvsj5a/CaBf3QqL/ 2Ug++haQEhFmxvepV+y26u7IID8es1lv7yUo72umOP+/+1Q/5D8Hr5WcGdv2EzP47C5p HvfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8UncsHNdMIsvpUAtoQR+iW3+vVF0t6rUk5pOWiyUgs8=; b=tIPHZk85hoIKDE+oLMMpy2vyum+UnmvG+8P73Iz0H0nVoPkxnpza4n9tSiM++NmKhr H3MGSvlOHK4G2snbK0pgFSIYl8UBSH4/xBNXG+6rOxGsDUESYrp9psfXmGla1bj60J8r wf/gjneoh+aLg2tfEstfweG54OZevSKgGDdBskcXLIOPa3PQY6vewrw0asaiDL3ydBzp YdGJ6c+e6NCEGki0Aw5QZMj4/eOYLbpsVe4UqfgtwZJb+XIdsoYY2NawKcHIk/MKEkZQ FwJsIOkMC9IElLXLGQvb9WlfkUEAh+7/SZfMpfcqyKgwTrRlQmWR5sjS2Ok9pZGo2r4Z sr0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BOeD6zMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r193-20020a632bca000000b003ab54e54914si12887010pgr.695.2022.05.09.02.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:10:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BOeD6zMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0C062044F9; Mon, 9 May 2022 02:00:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232629AbiEFPKZ (ORCPT + 99 others); Fri, 6 May 2022 11:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442675AbiEFPKX (ORCPT ); Fri, 6 May 2022 11:10:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 534276D195 for ; Fri, 6 May 2022 08:06:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 04CAFB83615 for ; Fri, 6 May 2022 15:06:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0254C385A8; Fri, 6 May 2022 15:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651849595; bh=Iptv53vFJdhpTSGnrF5kGqg5MMjPl4LVxL18KjOlJdU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BOeD6zMCOEgi2nA2dh7h5wq6MvnRPFqEYkIiCxR5QL93OvqcpQgmFDJiqfHl6S7E0 P2htJJ6aGVDVXyu8L5Mi6L8i04N1QQ4t95AprtM4Jl9amUCADeCsh2Ghd5gASS+jKf xR0FNfznCpAtqAloZ3ZIsh4BoL/KVDznYqZn4V0mVJ45yRRV/0S0SQlHn8LdP7bjA+ FV0yvq8C9GDQc3OI4JJ7+7cbQNJo+2kGvNlW8FE7X5tfta5IHfiGWUQKlrLgY/CRV3 Y9X0rXYOmjxTjmD2HjXjFLtlKEa3FmhPVQ+sDnE2gFo779YNP+UnLTuiEvAOzbE7fl DHa4iKDssodLg== Date: Fri, 6 May 2022 08:06:33 -0700 From: Nathan Chancellor To: Jens Axboe , Christoph Hellwig , Keith Busch , Sagi Grimberg Cc: Nick Desaulniers , Tom Rix , Kanchan Joshi , Anuj Gupta , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel test robot Subject: Re: [PATCH] nvme: Ensure ret is always initialized in Message-ID: References: <20220506150357.2443040-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220506150357.2443040-1-nathan@kernel.org> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ugh, subject should be: nvme: Ensure ret is always initialized in nvme_ns_head_chr_uring_cmd() I can resend if this is the correct thing to do. On Fri, May 06, 2022 at 08:03:58AM -0700, Nathan Chancellor wrote: > Clang warns: > > drivers/nvme/host/ioctl.c:674:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > if (ns) > ^~ > drivers/nvme/host/ioctl.c:677:9: note: uninitialized use occurs here > return ret; > ^~~ > drivers/nvme/host/ioctl.c:674:2: note: remove the 'if' if its condition is always true > if (ns) > ^~~~~~~ > drivers/nvme/host/ioctl.c:672:9: note: initialize the variable 'ret' to silence this warning > int ret; > ^ > = 0 > 1 error generated. > > Initialize ret to zero so that it cannot be used uninitialized. > > Fixes: 271ee3df5cca ("nvme: wire-up uring-cmd support for io-passthru on char-device.") > Link: https://github.com/ClangBuiltLinux/linux/issues/1630 > Reported-by: kernel test robot > Signed-off-by: Nathan Chancellor > --- > > Or alternatively, remove the 'if (ns)' if ns can never be NULL; I tried > going down the rabbit hole to see if that is possible but I got a little > lost :^) > > drivers/nvme/host/ioctl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c > index 9db88f2c15f8..3ad5285c1f96 100644 > --- a/drivers/nvme/host/ioctl.c > +++ b/drivers/nvme/host/ioctl.c > @@ -669,7 +669,7 @@ int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd, > struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev); > int srcu_idx = srcu_read_lock(&head->srcu); > struct nvme_ns *ns = nvme_find_path(head); > - int ret; > + int ret = 0; > > if (ns) > ret = nvme_ns_uring_cmd(ns, ioucmd, issue_flags); > > base-commit: 002b149a51a53facaf26d7c6f2c1fe718673683c > -- > 2.36.0 >