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: 9399ab61ad82 ("ndtest: Add dimms to the two buses")
Signed-off-by: Yang Yingliang <[email protected]>
---
tools/testing/nvdimm/test/ndtest.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/nvdimm/test/ndtest.c
b/tools/testing/nvdimm/test/ndtest.c
index 01ceb98c15a0..42954a6d0929 100644
--- a/tools/testing/nvdimm/test/ndtest.c
+++ b/tools/testing/nvdimm/test/ndtest.c
@@ -740,11 +740,11 @@ static int ndtest_dimm_register(struct ndtest_priv *priv,
dimm->dev = device_create_with_groups(ndtest_dimm_class,
&priv->pdev.dev,
0, dimm, dimm_attribute_groups,
"test_dimm%d", id);
- if (!dimm->dev) {
+ if (IS_ERR(dimm->dev)) {
pr_err("Could not create dimm device attributes\n");
- return -ENOMEM;
+ return PTR_ERR(dimm->dev);
}
return 0;
}
--
2.25.1