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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 135cec6 commit 991b5e2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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)