i2c: slave: add sanity check when unregistering
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 25 Jul 2020 19:50:53 +0000 (21:50 +0200)
committerWolfram Sang <wsa@kernel.org>
Tue, 28 Jul 2020 16:37:17 +0000 (18:37 +0200)
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Alain Volmat <alain.volmat@st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/i2c-core-slave.c

index 549751347e6c7ce662dae2b857cee42f6a1e0c83..1589179d5eb92af2b6dc5181b9a04b30efc05dfa 100644 (file)
@@ -58,6 +58,9 @@ int i2c_slave_unregister(struct i2c_client *client)
 {
        int ret;
 
+       if (IS_ERR_OR_NULL(client))
+               return -EINVAL;
+
        if (!client->adapter->algo->unreg_slave) {
                dev_err(&client->dev, "%s: not supported by adapter\n", __func__);
                return -EOPNOTSUPP;