Skip to content

Commit 991b5e2

Browse files
Dan Carpenterbroonie
authored andcommitted
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: 7b7982f ("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>
1 parent 135cec6 commit 991b5e2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/base/regmap/regmap-kunit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,10 +1925,10 @@ static int regmap_test_init(struct kunit *test)
19251925
test->priv = priv;
19261926

19271927
dev = kunit_device_register(test, "regmap_test");
1928-
priv->dev = get_device(dev);
1929-
if (!priv->dev)
1930-
return -ENODEV;
1928+
if (IS_ERR(dev))
1929+
return PTR_ERR(dev);
19311930

1931+
priv->dev = get_device(dev);
19321932
dev_set_drvdata(dev, test);
19331933

19341934
return 0;

0 commit comments

Comments
 (0)