From patchwork Mon Feb 13 10:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 56158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2266425wrn; Mon, 13 Feb 2023 02:18:42 -0800 (PST) X-Google-Smtp-Source: AK7set8mUcKRKUvfszh2eMUZ0sd2S/lfYtQ/852RsG9LvyJJJh3Y8Sk/uBrQr0JB+ge+HnVaORWy X-Received: by 2002:a50:d6c1:0:b0:4ac:c29d:5c4a with SMTP id l1-20020a50d6c1000000b004acc29d5c4amr3943401edj.29.1676283521891; Mon, 13 Feb 2023 02:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283521; cv=none; d=google.com; s=arc-20160816; b=TRdi3IohGdnw8MGXH8BLalJ99mPXCtuo3fS97LcY+F19+9zZvRx9H7lSjRy/RErqqn LOIzV/4spfRFf8De5fc/3TKZFnzfOS/tOJIr3WfxxnQ1a9HpJ9LlHTIQbaT23oE8yLrq EtwIjITAEKeHF9iAUdi+xle30gzLWgOb6ljUuQ/iVH/+ALCwb5oB3xBDInpQgo+g0nwo LFORR4J+B+MAJpLajs0tAM+M/oNgyet/+mOzhJKVIMFasu+oDfH+cLSYDadpi/7k2cpN 1cBIYZC1jJUSk83LwvINuwo850F9g+yTjLdOXgPn1Q0u7IF1RFAn7bEegepd0ZGA/B5S ZnJg== 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=xxiOxu4FDS4zTlUmZgjaGr0E3HMtJGwu0BsbJsCxfsw=; b=wJt7T/aHX3TdFKgOw7zlZslNcnPSeYCNy24qmZWJAYmJu5uaJMGH4OCKU52BNo3KWd WiBS3NfHjpVg9wuqaoDQKNz32Q6ZzfjCgMKHwGqG6ZO7WSNPVtdeH7FscebfL/10YzOY iaIlUUpKbgybFdEiD9t52z61+/L9C7a2u5eDwxmOGd5gYPefwk6wltyPAQ3UwuxdhJ8U 8ONBgYvFzTwxhiB027D1GT1/pX74wo6wtNgxbCpijxb3e4db/nHWxsgbW48UQJDeeStn IMrKfkkRrFBuneqE0SMwNH0swNFT2pzDfFwcvjU4AnWnD/bAFymxxp+rdQrMb7n8iIL1 R9Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UF30ZRTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020aa7ce0f000000b004aaaa3b7e44si13478300edv.522.2023.02.13.02.18.19; Mon, 13 Feb 2023 02:18:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UF30ZRTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230111AbjBMKMs (ORCPT + 99 others); Mon, 13 Feb 2023 05:12:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbjBMKMj (ORCPT ); Mon, 13 Feb 2023 05:12:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C271517178; Mon, 13 Feb 2023 02:12:24 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 1D65D60F6E; Mon, 13 Feb 2023 10:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22B65C433EF; Mon, 13 Feb 2023 10:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676283143; bh=tFR8Is7pavXEpFk5U0TVtxzOu/qBmPCX8MhgYgxKFFc=; h=From:To:Cc:Subject:Date:From; b=UF30ZRTO6xpYhEi8j35cVSgfYP9ZdsE6hYPizE+vpA3PNOkw6orROmUQjSjxtnqi4 92r0J751DcQr3xxPO7A9mFxmUc1YoXExPVVYb1rO8iYELTqC9CF+3jpcHuK7Hhy8fA XnXfJvkOZdNtIT1PsCZl3iATABuC3RlD6/2AvhBRVTijVmbEBw7edQw+aKXV0VMXfg s5hySEdjeKAOlgY1mKWFz+jJVFfzKqYevQ7KKZhZcJzpXOOpUKZmcSvlyJqlZmGXE0 Lsdvrcr8Ep2jvIIUdKUFVRE7tj2SP6dQ4voqLuqe8fspZQXLuH8oY0/Go/B979rjzl aG36IBVhjnNpA== From: Arnd Bergmann To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , Jonathan Cameron Cc: Arnd Bergmann , Dave Jiang , Dan Carpenter , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cxl: avoid returning uninitialized error code Date: Mon, 13 Feb 2023 11:12:11 +0100 Message-Id: <20230213101220.3821689-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757710670409831849?= X-GMAIL-MSGID: =?utf-8?q?1757710670409831849?= From: Arnd Bergmann The new cxl_add_to_region() function returns an uninitialized value on success: drivers/cxl/core/region.c:2628:6: error: variable 'rc' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if (IS_ERR(cxlr)) { ^~~~~~~~~~~~ drivers/cxl/core/region.c:2654:9: note: uninitialized use occurs here return rc; Simplify the logic to have the rc variable always initialized in the same place. Fixes: a32320b71f08 ("cxl/region: Add region autodiscovery") Signed-off-by: Arnd Bergmann --- drivers/cxl/core/region.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index fe1d8392870e..f29028148806 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2625,10 +2625,9 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled) cxlr = to_cxl_region(region_dev); mutex_unlock(&cxlrd->range_lock); - if (IS_ERR(cxlr)) { - rc = PTR_ERR(cxlr); + rc = PTR_ERR_OR_ZERO(cxlr); + if (rc) goto out; - } attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE);