Linux-i2c Archive on lore.kernel.org
 help / color / 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	[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	[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, back to index

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

Linux-i2c Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-i2c/0 linux-i2c/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-i2c linux-i2c/ https://lore.kernel.org/linux-i2c \
		linux-i2c@vger.kernel.org
	public-inbox-index linux-i2c

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-i2c


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git