Commit 991b5e2a authored by Dan Carpenter's avatar Dan Carpenter Committed by Mark Brown

regmap: kunit: Fix an NULL vs IS_ERR() check

The kunit_device_register() function returns error pointers, not NULL.
Passing an error pointer to get_device() will lead to an Oops.  Also
get_device() returns the same device you passed to it.  Fix it!  ;)

Fixes: 7b7982f1 ("regmap: kunit: Create a struct device for the regmap")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/b32e80cf-b385-40cd-b8ec-77ec73e07530@moroto.mountainSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 135cec6b
......@@ -1925,10 +1925,10 @@ static int regmap_test_init(struct kunit *test)
test->priv = priv;
dev = kunit_device_register(test, "regmap_test");
priv->dev = get_device(dev);
if (!priv->dev)
return -ENODEV;
if (IS_ERR(dev))
return PTR_ERR(dev);
priv->dev = get_device(dev);
dev_set_drvdata(dev, test);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment