diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2024-04-15 13:34:54 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-04-15 13:54:57 +0300 |
commit | 991b5e2aad870828669ca105f424ef1b2534f820 (patch) | |
tree | c12bffc2c9255601799a7dab973a89a269fb9617 /drivers/base/regmap | |
parent | 135cec6ba82ebffc0275c5228b4c4bf279fbf6f5 (diff) | |
download | linux-991b5e2aad870828669ca105f424ef1b2534f820.tar.xz |
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: 7b7982f14315 ("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>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r-- | drivers/base/regmap/regmap-kunit.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c index 44265dc2313d..9c5314785fc2 100644 --- a/drivers/base/regmap/regmap-kunit.c +++ b/drivers/base/regmap/regmap-kunit.c @@ -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; |