i2c: make i2c_unregister_device() ERR_PTR safe
diff mbox series

Message ID 20190819204825.2937-1-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series
  • i2c: make i2c_unregister_device() ERR_PTR safe
Related show

Commit Message

Wolfram Sang Aug. 19, 2019, 8:48 p.m. UTC
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>
---
 drivers/i2c/i2c-core-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Geert Uytterhoeven Aug. 29, 2019, 8:52 a.m. UTC | #1
On Mon, Aug 19, 2019 at 10:49 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> 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>

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang Aug. 29, 2019, 6:40 p.m. UTC | #2
On Mon, Aug 19, 2019 at 10:48:25PM +0200, Wolfram Sang wrote:
> 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>

Applied to for-current, thanks!

Patch
diff mbox series

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 76cb91e064b8..e5ba612ddc1e 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) {