All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check
@ 2024-04-15 10:34 Dan Carpenter
  2024-04-15 13:31 ` Richard Fitzgerald
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-04-15 10:34 UTC (permalink / raw
  To: Richard Fitzgerald
  Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	kernel-janitors

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;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check
  2024-04-15 10:34 [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check Dan Carpenter
@ 2024-04-15 13:31 ` Richard Fitzgerald
  2024-04-15 16:00 ` Markus Elfring
  2024-04-15 23:43 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2024-04-15 13:31 UTC (permalink / raw
  To: Dan Carpenter
  Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	kernel-janitors

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check
  2024-04-15 10:34 [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check Dan Carpenter
  2024-04-15 13:31 ` Richard Fitzgerald
@ 2024-04-15 16:00 ` Markus Elfring
  2024-04-15 23:43 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-04-15 16:00 UTC (permalink / raw
  To: Dan Carpenter, kernel-janitors, Richard Fitzgerald
  Cc: LKML, Greg Kroah-Hartman, Mark Brown, Rafael J. Wysocki

> 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. …

How do you think about to convert this adjustment into a patch series
with two update steps?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc4#n81

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check
  2024-04-15 10:34 [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check Dan Carpenter
  2024-04-15 13:31 ` Richard Fitzgerald
  2024-04-15 16:00 ` Markus Elfring
@ 2024-04-15 23:43 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-04-15 23:43 UTC (permalink / raw
  To: Richard Fitzgerald, Dan Carpenter
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	kernel-janitors

On Mon, 15 Apr 2024 13:34:54 +0300, 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!  ;)
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: kunit: Fix an NULL vs IS_ERR() check
      commit: 991b5e2aad870828669ca105f424ef1b2534f820

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-15 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 10:34 [PATCH] regmap: kunit: Fix an NULL vs IS_ERR() check Dan Carpenter
2024-04-15 13:31 ` Richard Fitzgerald
2024-04-15 16:00 ` Markus Elfring
2024-04-15 23:43 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.