All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] devlink: Return right error code in case of errors for region read
@ 2019-02-12  7:09 Parav Pandit
  2019-02-12 19:24 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Parav Pandit @ 2019-02-12  7:09 UTC (permalink / raw)
  To: jiri, davem, netdev; +Cc: parav

devlink_nl_cmd_region_read_dumpit() misses to return right error code on
most error conditions.
Return the right error code on such errors.

Fixes: 4e54795a27f5 ("devlink: Add support for region snapshot read command")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>

---
 net/core/devlink.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 5e2ef5a..8a198ba 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -3643,26 +3643,34 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
 		goto out;
 
 	devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs);
-	if (IS_ERR(devlink))
+	if (IS_ERR(devlink)) {
+		err = -ENODEV;
 		goto out;
+	}
 
 	mutex_lock(&devlink_mutex);
 	mutex_lock(&devlink->lock);
 
 	if (!attrs[DEVLINK_ATTR_REGION_NAME] ||
-	    !attrs[DEVLINK_ATTR_REGION_SNAPSHOT_ID])
+	    !attrs[DEVLINK_ATTR_REGION_SNAPSHOT_ID]) {
+		err = -EINVAL;
 		goto out_unlock;
+	}
 
 	region_name = nla_data(attrs[DEVLINK_ATTR_REGION_NAME]);
 	region = devlink_region_get_by_name(devlink, region_name);
-	if (!region)
+	if (!region) {
+		err = -EINVAL;
 		goto out_unlock;
+	}
 
 	hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
 			  &devlink_nl_family, NLM_F_ACK | NLM_F_MULTI,
 			  DEVLINK_CMD_REGION_READ);
-	if (!hdr)
+	if (!hdr) {
+		err = -EMSGSIZE;
 		goto out_unlock;
+	}
 
 	err = devlink_nl_put_handle(skb, devlink);
 	if (err)
@@ -3673,8 +3681,10 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
 		goto nla_put_failure;
 
 	chunks_attr = nla_nest_start(skb, DEVLINK_ATTR_REGION_CHUNKS);
-	if (!chunks_attr)
+	if (!chunks_attr) {
+		err = -EMSGSIZE;
 		goto nla_put_failure;
+	}
 
 	if (attrs[DEVLINK_ATTR_REGION_CHUNK_ADDR] &&
 	    attrs[DEVLINK_ATTR_REGION_CHUNK_LEN]) {
@@ -3715,7 +3725,7 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
 	mutex_unlock(&devlink->lock);
 	mutex_unlock(&devlink_mutex);
 out:
-	return 0;
+	return err;
 }
 
 struct devlink_info_req {
-- 
1.8.3.1


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

* Re: [PATCH net-next 1/2] devlink: Return right error code in case of errors for region read
  2019-02-12  7:09 [PATCH net-next 1/2] devlink: Return right error code in case of errors for region read Parav Pandit
@ 2019-02-12 19:24 ` David Miller
  2019-02-12 20:22   ` Parav Pandit
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-02-12 19:24 UTC (permalink / raw)
  To: parav; +Cc: jiri, netdev

From: Parav Pandit <parav@mellanox.com>
Date: Tue, 12 Feb 2019 01:09:19 -0600

> devlink_nl_cmd_region_read_dumpit() misses to return right error code on
> most error conditions.
> Return the right error code on such errors.
> 
> Fixes: 4e54795a27f5 ("devlink: Add support for region snapshot read command")
> Signed-off-by: Parav Pandit <parav@mellanox.com>
> Acked-by: Jiri Pirko <jiri@mellanox.com>

This has conflicts with the locking changes I applied earlier today.

Please respin, thanks.

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

* RE: [PATCH net-next 1/2] devlink: Return right error code in case of errors for region read
  2019-02-12 19:24 ` David Miller
@ 2019-02-12 20:22   ` Parav Pandit
  0 siblings, 0 replies; 3+ messages in thread
From: Parav Pandit @ 2019-02-12 20:22 UTC (permalink / raw)
  To: David Miller; +Cc: Jiri Pirko, netdev



> -----Original Message-----
> From: David Miller <davem@davemloft.net>
> Sent: Tuesday, February 12, 2019 1:25 PM
> To: Parav Pandit <parav@mellanox.com>
> Cc: Jiri Pirko <jiri@mellanox.com>; netdev@vger.kernel.org
> Subject: Re: [PATCH net-next 1/2] devlink: Return right error code in case of
> errors for region read
> 
> From: Parav Pandit <parav@mellanox.com>
> Date: Tue, 12 Feb 2019 01:09:19 -0600
> 
> > devlink_nl_cmd_region_read_dumpit() misses to return right error code
> > on most error conditions.
> > Return the right error code on such errors.
> >
> > Fixes: 4e54795a27f5 ("devlink: Add support for region snapshot read
> > command")
> > Signed-off-by: Parav Pandit <parav@mellanox.com>
> > Acked-by: Jiri Pirko <jiri@mellanox.com>
> 
> This has conflicts with the locking changes I applied earlier today.
> 
> Please respin, thanks.
Ok. sending rebased v2.

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

end of thread, other threads:[~2019-02-12 20:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12  7:09 [PATCH net-next 1/2] devlink: Return right error code in case of errors for region read Parav Pandit
2019-02-12 19:24 ` David Miller
2019-02-12 20:22   ` Parav Pandit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.