mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Mark Brown <broonie@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check
Date: Mon, 15 Apr 2024 14:31:21 +0100	[thread overview]
Message-ID: <99ba78fa-1d09-4072-849b-f994c87c1db6@opensource.cirrus.com> (raw)
In-Reply-To: <b32e80cf-b385-40cd-b8ec-77ec73e07530@moroto.mountain>

On 15/04/2024 11:34, Dan Carpenter wrote:
> 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>
> ---
>   drivers/base/regmap/regmap-kunit.c | 6 +++---
>   1 file 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;

Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>

  reply	other threads:[~2024-04-15 13:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 10:34 Dan Carpenter
2024-04-15 13:31 ` Richard Fitzgerald [this message]
2024-04-15 16:00 ` Markus Elfring
2024-04-15 23:43 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99ba78fa-1d09-4072-849b-f994c87c1db6@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®