Skip to content

Commit fa0195d

Browse files
Wolfram Sanggregkh
authored andcommitted
i2c: slave: improve sanity check when registering
[ Upstream commit 1b1be3b ] Add check for ERR_PTR and simplify code while here. Signed-off-by: Wolfram Sang <[email protected]> Reviewed-by: Alain Volmat <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4bba72b commit fa0195d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/i2c/i2c-core-slave.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
1818
{
1919
int ret;
2020

21-
if (!client || !slave_cb) {
22-
WARN(1, "insufficient data\n");
21+
if (WARN(IS_ERR_OR_NULL(client) || !slave_cb, "insufficient data\n"))
2322
return -EINVAL;
24-
}
2523

2624
if (!(client->flags & I2C_CLIENT_SLAVE))
2725
dev_warn(&client->dev, "%s: client slave flag not set. You might see address collisions\n",

0 commit comments

Comments
 (0)