diff mbox series

[1/2] nfit_test: fix return value check in nfit_test_dimm_init()

Message ID 20221125092721.9433-2-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series tools/testing/nvdimm: fix return value check | expand

Commit Message

Yang Yingliang Nov. 25, 2022, 9:27 a.m. UTC
If device_create_with_groups() fails, it returns ERR_PTR()
and never return NULL, so replace NULL pointer check with
IS_ERR() to fix this problem.

Fixes: 231bf117aada ("tools/testing/nvdimm: unit test for acpi_nvdimm_notify()")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 tools/testing/nvdimm/test/nfit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index c75abb497a1a..220315091143 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -1833,10 +1833,10 @@  static int nfit_test_dimm_init(struct nfit_test *t)
 		t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm,
 				&t->pdev.dev, 0, NULL,
 				nfit_test_dimm_attribute_groups,
 				"test_dimm%d", i + t->dcr_idx);
-		if (!t->dimm_dev[i])
-			return -ENOMEM;
+		if (IS_ERR(t->dimm_dev[i]))
+			return PTR_ERR(t->dimm_dev[i]);
 	}
 	return 0;
 }