tools/testing/nvdimm: fix return value check
cover tools/testing/nvdimm: fix return value check
This patchset fixes two return value check problems when device_create_with_groups fails.
Yang Yingliang (2):
nfit_test: fix return value check in nfit_test_dimm_init()
ndtest: fix return value check in ndtest_dimm_register()
tools/testing/nvdimm/test/ndtest.c | 4 ++-- tools/testing/nvdimm/test/nfit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 nfit_test: fix return value check in nfit_test_dimm_init()
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(-)
tools/testing/nvdimm/test/nfit.c +2 -2
@@ -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 ; }
Signature · 1 line
2.25.1
PATCH 2/2 ndtest: fix return value check in ndtest_dimm_register()
In reply to Yang YingliangIf 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(-)
tools/testing/nvdimm/test/ndtest.c +2 -2
@@ -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 ; }
Signature · 1 line
2.25.1