提交 6ea438ec 编写于 作者: D David Brownell 提交者: Jean Delvare

i2c: i2c_use_client() defends against NULL

Defend the i2c refcount calls against NULL pointers, as is important
(and conventional) for such calls.  Note that none of the current
callers of i2c_use_client() use its return value.

[JD: I hate this but apparently all the other subsystems do it so...]
Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 a1cdedac
...@@ -866,8 +866,9 @@ EXPORT_SYMBOL(i2c_detach_client); ...@@ -866,8 +866,9 @@ EXPORT_SYMBOL(i2c_detach_client);
*/ */
struct i2c_client *i2c_use_client(struct i2c_client *client) struct i2c_client *i2c_use_client(struct i2c_client *client)
{ {
get_device(&client->dev); if (client && get_device(&client->dev))
return client; return client;
return NULL;
} }
EXPORT_SYMBOL(i2c_use_client); EXPORT_SYMBOL(i2c_use_client);
...@@ -879,7 +880,8 @@ EXPORT_SYMBOL(i2c_use_client); ...@@ -879,7 +880,8 @@ EXPORT_SYMBOL(i2c_use_client);
*/ */
void i2c_release_client(struct i2c_client *client) void i2c_release_client(struct i2c_client *client)
{ {
put_device(&client->dev); if (client)
put_device(&client->dev);
} }
EXPORT_SYMBOL(i2c_release_client); EXPORT_SYMBOL(i2c_release_client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部