LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>
Cc: <dan.j.williams@intel.com>, <ben.widawsky@intel.com>
Subject: [PATCH -next] tools/testing/cxl: Fix error return code in cxl_test_init()
Date: Thu, 26 Aug 2021 11:42:52 +0800	[thread overview]
Message-ID: <20210826034252.3373142-1-yangyingliang@huawei.com> (raw)

Return a negative error code when platform_device_alloc() or
alloc_memdev() fail.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 tools/testing/cxl/test/cxl.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
index 314b09d40333..92735e2e7146 100644
--- a/tools/testing/cxl/test/cxl.c
+++ b/tools/testing/cxl/test/cxl.c
@@ -472,8 +472,10 @@ static __init int cxl_test_init(void)
 		struct platform_device *pdev;
 
 		pdev = platform_device_alloc("cxl_host_bridge", i);
-		if (!pdev)
+		if (!pdev) {
+			rc = -ENOMEM;
 			goto err_bridge;
+		}
 
 		mock_companion(adev, &pdev->dev);
 		rc = platform_device_add(pdev);
@@ -490,8 +492,10 @@ static __init int cxl_test_init(void)
 		struct platform_device *pdev;
 
 		pdev = platform_device_alloc("cxl_root_port", i);
-		if (!pdev)
+		if (!pdev) {
+			rc = -ENOMEM;
 			goto err_port;
+		}
 		pdev->dev.parent = &bridge->dev;
 
 		rc = platform_device_add(pdev);
@@ -508,8 +512,10 @@ static __init int cxl_test_init(void)
 		struct platform_device *pdev;
 
 		pdev = alloc_memdev(i);
-		if (!pdev)
+		if (!pdev) {
+			rc = -ENOMEM;
 			goto err_mem;
+		}
 		pdev->dev.parent = &port->dev;
 
 		rc = platform_device_add(pdev);
@@ -521,8 +527,10 @@ static __init int cxl_test_init(void)
 	}
 
 	cxl_acpi = platform_device_alloc("cxl_acpi", 0);
-	if (!cxl_acpi)
+	if (!cxl_acpi) {
+		rc = -ENOMEM;
 		goto err_mem;
+	}
 
 	mock_companion(&acpi0017_mock, &cxl_acpi->dev);
 	acpi0017_mock.dev.bus = &platform_bus_type;
-- 
2.25.1


                 reply	other threads:[~2021-08-26  3:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210826034252.3373142-1-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=ben.widawsky@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH -next] tools/testing/cxl: Fix error return code in cxl_test_init()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).