linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] i2c: slave: improve sanity checks when un-/registering
@ 2020-07-25 19:50 Wolfram Sang
  2020-07-25 19:50 ` [PATCH 1/2] i2c: slave: improve sanity check when registering Wolfram Sang
  2020-07-25 19:50 ` [PATCH 2/2] i2c: slave: add sanity check when unregistering Wolfram Sang
  0 siblings, 2 replies; 7+ messages in thread
From: Wolfram Sang @ 2020-07-25 19:50 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alain Volmat, Wolfram Sang

Unregistering was completly missing the check, registering was missing
ERR_PTR conditions. Fix both.

Wolfram Sang (2):
  i2c: slave: improve sanity check when registering
  i2c: slave: add sanity check when unregistering driver

 drivers/i2c/i2c-core-slave.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] i2c: slave: improve sanity check when registering
  2020-07-25 19:50 [PATCH 0/2] i2c: slave: improve sanity checks when un-/registering Wolfram Sang
@ 2020-07-25 19:50 ` Wolfram Sang
  2020-07-28 12:01   ` Alain Volmat
  2020-07-28 16:40   ` Wolfram Sang
  2020-07-25 19:50 ` [PATCH 2/2] i2c: slave: add sanity check when unregistering Wolfram Sang
  1 sibling, 2 replies; 7+ messages in thread
From: Wolfram Sang @ 2020-07-25 19:50 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alain Volmat, Wolfram Sang

Add check for ERR_PTR and simplify code while here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-core-slave.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index 5427f047faf0..549751347e6c 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -18,10 +18,8 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
 {
 	int ret;
 
-	if (!client || !slave_cb) {
-		WARN(1, "insufficient data\n");
+	if (WARN(IS_ERR_OR_NULL(client) || !slave_cb, "insufficient data\n"))
 		return -EINVAL;
-	}
 
 	if (!(client->flags & I2C_CLIENT_SLAVE))
 		dev_warn(&client->dev, "%s: client slave flag not set. You might see address collisions\n",
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] i2c: slave: add sanity check when unregistering
  2020-07-25 19:50 [PATCH 0/2] i2c: slave: improve sanity checks when un-/registering Wolfram Sang
  2020-07-25 19:50 ` [PATCH 1/2] i2c: slave: improve sanity check when registering Wolfram Sang
@ 2020-07-25 19:50 ` Wolfram Sang
  2020-07-28 12:01   ` Alain Volmat
  2020-07-28 16:40   ` Wolfram Sang
  1 sibling, 2 replies; 7+ messages in thread
From: Wolfram Sang @ 2020-07-25 19:50 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alain Volmat, Wolfram Sang

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-core-slave.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index 549751347e6c..1589179d5eb9 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] i2c: slave: improve sanity check when registering
  2020-07-25 19:50 ` [PATCH 1/2] i2c: slave: improve sanity check when registering Wolfram Sang
@ 2020-07-28 12:01   ` Alain Volmat
  2020-07-28 16:40   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Alain Volmat @ 2020-07-28 12:01 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c

Hi Wolfram,

Reviewed-by: Alain Volmat <alain.volmat@st.com>

Alain

On Sat, Jul 25, 2020 at 09:50:52PM +0200, Wolfram Sang wrote:
> Add check for ERR_PTR and simplify code while here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/i2c/i2c-core-slave.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
> index 5427f047faf0..549751347e6c 100644
> --- a/drivers/i2c/i2c-core-slave.c
> +++ b/drivers/i2c/i2c-core-slave.c
> @@ -18,10 +18,8 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
>  {
>  	int ret;
>  
> -	if (!client || !slave_cb) {
> -		WARN(1, "insufficient data\n");
> +	if (WARN(IS_ERR_OR_NULL(client) || !slave_cb, "insufficient data\n"))
>  		return -EINVAL;
> -	}
>  
>  	if (!(client->flags & I2C_CLIENT_SLAVE))
>  		dev_warn(&client->dev, "%s: client slave flag not set. You might see address collisions\n",
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] i2c: slave: add sanity check when unregistering
  2020-07-25 19:50 ` [PATCH 2/2] i2c: slave: add sanity check when unregistering Wolfram Sang
@ 2020-07-28 12:01   ` Alain Volmat
  2020-07-28 16:40   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Alain Volmat @ 2020-07-28 12:01 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c

Hi Wolfram,

Reviewed-by: Alain Volmat <alain.volmat@st.com>

Alain

On Sat, Jul 25, 2020 at 09:50:53PM +0200, Wolfram Sang wrote:
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/i2c/i2c-core-slave.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
> index 549751347e6c..1589179d5eb9 100644
> --- a/drivers/i2c/i2c-core-slave.c
> +++ b/drivers/i2c/i2c-core-slave.c
> @@ -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;
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] i2c: slave: improve sanity check when registering
  2020-07-25 19:50 ` [PATCH 1/2] i2c: slave: improve sanity check when registering Wolfram Sang
  2020-07-28 12:01   ` Alain Volmat
@ 2020-07-28 16:40   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2020-07-28 16:40 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alain Volmat

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

On Sat, Jul 25, 2020 at 09:50:52PM +0200, Wolfram Sang wrote:
> Add check for ERR_PTR and simplify code while here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] i2c: slave: add sanity check when unregistering
  2020-07-25 19:50 ` [PATCH 2/2] i2c: slave: add sanity check when unregistering Wolfram Sang
  2020-07-28 12:01   ` Alain Volmat
@ 2020-07-28 16:40   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2020-07-28 16:40 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alain Volmat

[-- Attachment #1: Type: text/plain, Size: 161 bytes --]

On Sat, Jul 25, 2020 at 09:50:53PM +0200, Wolfram Sang wrote:
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-28 16:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25 19:50 [PATCH 0/2] i2c: slave: improve sanity checks when un-/registering Wolfram Sang
2020-07-25 19:50 ` [PATCH 1/2] i2c: slave: improve sanity check when registering Wolfram Sang
2020-07-28 12:01   ` Alain Volmat
2020-07-28 16:40   ` Wolfram Sang
2020-07-25 19:50 ` [PATCH 2/2] i2c: slave: add sanity check when unregistering Wolfram Sang
2020-07-28 12:01   ` Alain Volmat
2020-07-28 16:40   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).