提交 2236baa7 编写于 作者: J Jean Delvare 提交者: Jean Delvare

i2c: Sanity checks on adapter registration

Make sure I2C adapters being registered have the required struct
fields set. If they don't, problems will happen later.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 e1e18ee1
......@@ -848,6 +848,18 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
goto out_list;
}
/* Sanity checks */
if (unlikely(adap->name[0] == '\0')) {
pr_err("i2c-core: Attempt to register an adapter with "
"no name!\n");
return -EINVAL;
}
if (unlikely(!adap->algo)) {
pr_err("i2c-core: Attempt to register adapter '%s' with "
"no algo!\n", adap->name);
return -EINVAL;
}
rt_mutex_init(&adap->bus_lock);
mutex_init(&adap->userspace_clients_lock);
INIT_LIST_HEAD(&adap->userspace_clients);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册