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 <[email protected]>
---
 tools/testing/nvdimm/test/nfit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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;
 }
 
-- 
2.25.1


Reply via email to