linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: ipwireless: fix error handling
@ 2020-08-16  7:43 Tong Zhang
  2020-08-18  8:35 ` Jiri Slaby
  0 siblings, 1 reply; 6+ messages in thread
From: Tong Zhang @ 2020-08-16  7:43 UTC (permalink / raw)
  To: jikos, dsterba, gregkh, jirislaby, linux-kernel; +Cc: ztong0001

ipwireless_send_packet() can only return 0 on success and -ENOMEM on
error, the caller should check non zero for error condition

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
 drivers/tty/ipwireless/network.c | 4 ++--
 drivers/tty/ipwireless/tty.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
index cf20616340a1..b6f677f4004c 100644
--- a/drivers/tty/ipwireless/network.c
+++ b/drivers/tty/ipwireless/network.c
@@ -117,7 +117,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       skb->len,
 					       notify_packet_sent,
 					       network);
-			if (ret == -1) {
+			if (ret != 0) {
 				skb_pull(skb, 2);
 				return 0;
 			}
@@ -134,7 +134,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       notify_packet_sent,
 					       network);
 			kfree(buf);
-			if (ret == -1)
+			if (ret != 0)
 				return 0;
 		}
 		kfree_skb(skb);
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index fad3401e604d..0230e0fd3937 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -218,7 +218,7 @@ static int ipw_write(struct tty_struct *linux_tty,
 	ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
 			       buf, count,
 			       ipw_write_packet_sent_callback, tty);
-	if (ret == -1) {
+	if (ret != 0) {
 		mutex_unlock(&tty->ipw_tty_mutex);
 		return 0;
 	}
-- 
2.25.1


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

* Re: [PATCH] tty: ipwireless: fix error handling
  2020-08-16  7:43 [PATCH] tty: ipwireless: fix error handling Tong Zhang
@ 2020-08-18  8:35 ` Jiri Slaby
  2020-08-18 16:03   ` [PATCH v2] " Tong Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2020-08-18  8:35 UTC (permalink / raw)
  To: Tong Zhang, jikos, dsterba, gregkh, linux-kernel

On 16. 08. 20, 9:43, Tong Zhang wrote:
> ipwireless_send_packet() can only return 0 on success and -ENOMEM on
> error, the caller should check non zero for error condition
> 
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
>  drivers/tty/ipwireless/network.c | 4 ++--
>  drivers/tty/ipwireless/tty.c     | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
> index cf20616340a1..b6f677f4004c 100644
> --- a/drivers/tty/ipwireless/network.c
> +++ b/drivers/tty/ipwireless/network.c
> @@ -117,7 +117,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
>  					       skb->len,
>  					       notify_packet_sent,
>  					       network);
> -			if (ret == -1) {
> +			if (ret != 0) {

More consistent (with the rest of the kernel), would be to check "< 0"
in all the places.

>  				skb_pull(skb, 2);
>  				return 0;
>  			}
> @@ -134,7 +134,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
>  					       notify_packet_sent,
>  					       network);
>  			kfree(buf);
> -			if (ret == -1)
> +			if (ret != 0)
>  				return 0;
>  		}
>  		kfree_skb(skb);
> diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
> index fad3401e604d..0230e0fd3937 100644
> --- a/drivers/tty/ipwireless/tty.c
> +++ b/drivers/tty/ipwireless/tty.c
> @@ -218,7 +218,7 @@ static int ipw_write(struct tty_struct *linux_tty,
>  	ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
>  			       buf, count,
>  			       ipw_write_packet_sent_callback, tty);
> -	if (ret == -1) {
> +	if (ret != 0) {
>  		mutex_unlock(&tty->ipw_tty_mutex);
>  		return 0;
>  	}
> 


-- 
js
suse labs

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

* [PATCH v2] tty: ipwireless: fix error handling
  2020-08-18  8:35 ` Jiri Slaby
@ 2020-08-18 16:03   ` Tong Zhang
  2020-08-21  9:28     ` David Sterba
  0 siblings, 1 reply; 6+ messages in thread
From: Tong Zhang @ 2020-08-18 16:03 UTC (permalink / raw)
  To: jikos, dsterba, gregkh, jirislaby, ztong0001, linux-kernel

ipwireless_send_packet() can only return 0 on success and -ENOMEM on
error, the caller should check non zero for error condition

v2: - According to Jiri's comment, I made the checking consistent with
the rest of the kernel. I also rebased the code using f684668a24ec.
Thank you Jiri!

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
 drivers/tty/ipwireless/network.c | 4 ++--
 drivers/tty/ipwireless/tty.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
index cf20616340a1..fe569f6294a2 100644
--- a/drivers/tty/ipwireless/network.c
+++ b/drivers/tty/ipwireless/network.c
@@ -117,7 +117,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       skb->len,
 					       notify_packet_sent,
 					       network);
-			if (ret == -1) {
+			if (ret < 0) {
 				skb_pull(skb, 2);
 				return 0;
 			}
@@ -134,7 +134,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       notify_packet_sent,
 					       network);
 			kfree(buf);
-			if (ret == -1)
+			if (ret < 0)
 				return 0;
 		}
 		kfree_skb(skb);
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index fad3401e604d..23584769fc29 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -218,7 +218,7 @@ static int ipw_write(struct tty_struct *linux_tty,
 	ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
 			       buf, count,
 			       ipw_write_packet_sent_callback, tty);
-	if (ret == -1) {
+	if (ret < 0) {
 		mutex_unlock(&tty->ipw_tty_mutex);
 		return 0;
 	}
-- 
2.25.1


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

* Re: [PATCH v2] tty: ipwireless: fix error handling
  2020-08-18 16:03   ` [PATCH v2] " Tong Zhang
@ 2020-08-21  9:28     ` David Sterba
  2020-08-21 16:19       ` [PATCH v3] " Tong Zhang
  2020-08-21 16:20       ` [PATCH v2] " Tong Zhang
  0 siblings, 2 replies; 6+ messages in thread
From: David Sterba @ 2020-08-21  9:28 UTC (permalink / raw)
  To: Tong Zhang; +Cc: jikos, dsterba, gregkh, jirislaby, linux-kernel

On Tue, Aug 18, 2020 at 12:03:58PM -0400, Tong Zhang wrote:
> ipwireless_send_packet() can only return 0 on success and -ENOMEM on
> error, the caller should check non zero for error condition

Thanks.

Acked-by: David Sterba <dsterba@suse.com>

---
> v2: - According to Jiri's comment, I made the checking consistent with
> the rest of the kernel. I also rebased the code using f684668a24ec.
> Thank you Jiri!
---

This paragraph should not be in the changelog. The patches to ipwireless
go via Greg's tree, please send an updated v3 so he can just apply that
without further edits.  Thanks.

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

* [PATCH v3] tty: ipwireless: fix error handling
  2020-08-21  9:28     ` David Sterba
@ 2020-08-21 16:19       ` Tong Zhang
  2020-08-21 16:20       ` [PATCH v2] " Tong Zhang
  1 sibling, 0 replies; 6+ messages in thread
From: Tong Zhang @ 2020-08-21 16:19 UTC (permalink / raw)
  To: jikos, dsterba, gregkh, jirislaby, ztong0001, linux-kernel

ipwireless_send_packet() can only return 0 on success and -ENOMEM on
error, the caller should check non zero for error condition

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---

v2: - According to Jiri's comment, I made the checking consistent with
the rest of the kernel. I also rebased the code using f684668a24ec.
Thank you Jiri!
v3: fix commit log according to David's comment, and rebased using
Greg's tty-testing tree. Thank you David!

 drivers/tty/ipwireless/network.c | 4 ++--
 drivers/tty/ipwireless/tty.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
index cf20616340a1..fe569f6294a2 100644
--- a/drivers/tty/ipwireless/network.c
+++ b/drivers/tty/ipwireless/network.c
@@ -117,7 +117,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       skb->len,
 					       notify_packet_sent,
 					       network);
-			if (ret == -1) {
+			if (ret < 0) {
 				skb_pull(skb, 2);
 				return 0;
 			}
@@ -134,7 +134,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
 					       notify_packet_sent,
 					       network);
 			kfree(buf);
-			if (ret == -1)
+			if (ret < 0)
 				return 0;
 		}
 		kfree_skb(skb);
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index fad3401e604d..23584769fc29 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -218,7 +218,7 @@ static int ipw_write(struct tty_struct *linux_tty,
 	ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
 			       buf, count,
 			       ipw_write_packet_sent_callback, tty);
-	if (ret == -1) {
+	if (ret < 0) {
 		mutex_unlock(&tty->ipw_tty_mutex);
 		return 0;
 	}
-- 
2.25.1


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

* Re: [PATCH v2] tty: ipwireless: fix error handling
  2020-08-21  9:28     ` David Sterba
  2020-08-21 16:19       ` [PATCH v3] " Tong Zhang
@ 2020-08-21 16:20       ` Tong Zhang
  1 sibling, 0 replies; 6+ messages in thread
From: Tong Zhang @ 2020-08-21 16:20 UTC (permalink / raw)
  To: dsterba, Tong Zhang, jikos, dsterba, Greg KH, Jiri Slaby, linux-kernel

On Fri, Aug 21, 2020 at 5:29 AM David Sterba <dsterba@suse.cz> wrote:
> This paragraph should not be in the changelog. The patches to ipwireless
> go via Greg's tree, please send an updated v3 so he can just apply that
> without further edits.  Thanks.

Thanks David! I've made another patch - hope this one works.

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

end of thread, other threads:[~2020-08-21 16:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16  7:43 [PATCH] tty: ipwireless: fix error handling Tong Zhang
2020-08-18  8:35 ` Jiri Slaby
2020-08-18 16:03   ` [PATCH v2] " Tong Zhang
2020-08-21  9:28     ` David Sterba
2020-08-21 16:19       ` [PATCH v3] " Tong Zhang
2020-08-21 16:20       ` [PATCH v2] " Tong Zhang

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).