mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
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: 7b7982f143 ("regmap: kunit: Create a struct device for the regmap")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/b32e80cf-b385-40cd-b8ec-77ec73e07530@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
135cec6ba8
commit
991b5e2aad
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user