Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp611198pxb; Wed, 25 Aug 2021 10:38:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKjwt7Z1wwShrEaTYh7kMslwAX0C9X4LKpMF+B6fFdtvIYfBXTAiWk5Gr9fafHBz+JwO7+ X-Received: by 2002:a17:906:6808:: with SMTP id k8mr150403ejr.138.1629913114386; Wed, 25 Aug 2021 10:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629913114; cv=none; d=google.com; s=arc-20160816; b=LUs/7X+SHvxbUBwjbyTomZVk9nVxcZx3bZp7UZwYiKZLzGAF9IqITQ0JeU5IgaVacY N/BBaqwnbs6/IRq0CFUQ9AjsoA/xyhaEYGpZ+6mOUuWzrQ5eBCRRFVw9PqJH9hfOQGVj j9sGVa8jL1jjd1yld/WYAC++DnnnsIrW+RiKU/LVcnf6XsAIUypzltArj+qzQKXWcEBq EJ/mX3Md/wkp4yyW9A7x3ituS/Mn58jiu0XKTnYg7nhzuT95G4TfG1y9ehHs+K0Jq8gq 0hE9kWzuAiCptJoBrCMEHeEHXK+OI4gLDlUocILl3+nEWVGtYP11x4EuR13h6MYJA6oc CRqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Mo75y37FlwpGdzOmdwcBnw278Knu/H6/Idmm5Bb+4og=; b=rsMYn7z53EoDfXO1qO87PRNeOh/lgeXgk1vsCz8dGHoIb3sXtwnkb1wGTpPeLfD/vp vXnrCh51sNnqsod42SeUsvKA9IDr28IIh1fmqUnnQ4IIbfupu7sQRyYkDPps4PduBYpa TRiHXqKEl73gbmT0my6pXUkIAfwARH7hZXScbfYFD1zi/jOuXAMG/yHiqvY4NoYq3l+H T+ELTaDxZFAmbE9Xp2NqKEXoOmnV8z5hpKjOXLGcYWpSZJbt2VjMi1XmnBHZT+sjrO9L MdbzrMYtZyp9tGJ4UUmvrslkb1ri0FBh0oZYCxcKo1cFZCWJ/oMQOCktwjcp/LlNVWpm wqbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ndplRsWu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si535794edi.560.2021.08.25.10.38.09; Wed, 25 Aug 2021 10:38:34 -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=@kernel.org header.s=k20201202 header.b=ndplRsWu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242385AbhHYRe0 (ORCPT + 99 others); Wed, 25 Aug 2021 13:34:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:53050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242368AbhHYReW (ORCPT ); Wed, 25 Aug 2021 13:34:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58CD1610CB; Wed, 25 Aug 2021 17:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629912816; bh=StKbEN+KHuyLQXJf+AEBcWvhQNliMxECNYX4oGLIgpo=; h=From:To:Cc:Subject:Date:From; b=ndplRsWuWqTCLGHZslou+OzvktnNhlT1X8aBpbPPyGCeTfHzNTYaN0lTYNRHiwGNo YTeaIPWjJ6uvm9D0vnbn2Y2i1z2Hg1GLBl+LXCrd3jgLQRkmB+5rO4YUh2eL3ICbKx CkwSP/W4GIz9cFuMJIClVSpLMUJOaaAPzgW2ba1T+OgsGzULrSdy3o8UN1RT6I6nGl BEJTqLffS1AsIlwNXBuABLFoFOYYKScTYzJbrBVQVmm6bylcvmZ+m5TX6YBHvjeE9+ JzxSpUND85J/OJeUeGsTiJueEdiiFxm4TJSkbdHU05kisFg1JbB93jGoKbVYnQvfFD hyxnqd1QIYzJw== From: Nathan Chancellor To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams Cc: Nick Desaulniers , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] cxl/core: Avoid using dev uninitialized in devm_cxl_add_decoder() Date: Wed, 25 Aug 2021 10:33:01 -0700 Message-Id: <20210825173301.358381-1-nathan@kernel.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns: drivers/cxl/core/bus.c:527:6: warning: variable 'dev' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (rc) ^~ drivers/cxl/core/bus.c:541:13: note: uninitialized use occurs here put_device(dev); ^~~ drivers/cxl/core/bus.c:527:2: note: remove the 'if' if its condition is always false if (rc) ^~~~~~~ drivers/cxl/core/bus.c:507:6: warning: variable 'dev' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (cxld->interleave_ways < 1) { ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/cxl/core/bus.c:541:13: note: uninitialized use occurs here put_device(dev); ^~~ drivers/cxl/core/bus.c:507:2: note: remove the 'if' if its condition is always false if (cxld->interleave_ways < 1) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/cxl/core/bus.c:498:20: note: initialize the variable 'dev' to silence this warning struct device *dev; ^ = NULL 2 warnings generated. Return the error code directly rather than attempting to call device_put() with an uninitialized pointer. Fixes: b7ca54b62551 ("cxl/core: Split decoder setup into alloc + add") Signed-off-by: Nathan Chancellor --- drivers/cxl/core/bus.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/bus.c b/drivers/cxl/core/bus.c index 1320a996220a..f4d5319e29e3 100644 --- a/drivers/cxl/core/bus.c +++ b/drivers/cxl/core/bus.c @@ -504,10 +504,8 @@ int devm_cxl_add_decoder(struct device *host, struct cxl_decoder *cxld, if (IS_ERR(cxld)) return PTR_ERR(cxld); - if (cxld->interleave_ways < 1) { - rc = -EINVAL; - goto err; - } + if (cxld->interleave_ways < 1) + return -EINVAL; device_lock(&port->dev); if (list_empty(&port->dports)) @@ -525,7 +523,7 @@ int devm_cxl_add_decoder(struct device *host, struct cxl_decoder *cxld, } device_unlock(&port->dev); if (rc) - goto err; + return rc; dev = &cxld->dev; rc = dev_set_name(dev, "decoder%d.%d", port->id, cxld->id); base-commit: 036a16a39e2fab9bf7279201d04cf7e90993521f -- 2.33.0