From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date: Mon, 19 Aug 2019 20:48:25 +0000 (+0200)
Subject: i2c: make i2c_unregister_device() ERR_PTR safe
X-Git-Tag: v5.3-rc7~7^2~6
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=689f535843ac2633b395cfc494446326d03efab6;p=users%2Fjedix%2Flinux-maple.git

i2c: make i2c_unregister_device() ERR_PTR safe

We are moving towards returning ERR_PTRs when i2c_new_*_device() calls
fail. Make sure its counterpart for unregistering handles ERR_PTRs as
well.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index f26ed495d384..9c440fa6a3dd 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -832,7 +832,7 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
-	if (!client)
+	if (IS_ERR_OR_NULL(client))
 		return;
 
 	if (client->dev.of_node) {