All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tty: n_gsm: delete DISC command frame as requester
@ 2021-07-05  2:28 Zhenguo Zhao
  2021-07-05  6:20 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Zhenguo Zhao @ 2021-07-05  2:28 UTC (permalink / raw)
  To: zhenguo6858, gregkh, jirislaby; +Cc: linux-kernel

From: Zhenguo Zhao <Zhenguo.Zhao1@unisoc.com>

as initiator,it need to send DISC command ,as requester,there is
no need to send the DISC control frame,it will cause redundant data.

Signed-off-by: Zhenguo Zhao <Zhenguo.Zhao1@unisoc.com>
---
 drivers/tty/n_gsm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 5fea02c..f8e5935 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2050,7 +2050,8 @@ static int gsm_disconnect(struct gsm_mux *gsm)
 	del_timer_sync(&gsm->t2_timer);
 	/* Now we are sure T2 has stopped */
 
-	gsm_dlci_begin_close(dlci);
+	if (gsm->initiator)
+		gsm_dlci_begin_close(dlci);
 	wait_event_interruptible(gsm->event,
 				dlci->state == DLCI_CLOSED);
 
@@ -3014,6 +3015,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
 static void gsmtty_close(struct tty_struct *tty, struct file *filp)
 {
 	struct gsm_dlci *dlci = tty->driver_data;
+	struct gsm_mux *gsm = dlci->gsm;
 
 	if (dlci == NULL)
 		return;
@@ -3024,7 +3026,8 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp)
 	mutex_unlock(&dlci->mutex);
 	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
 		return;
-	gsm_dlci_begin_close(dlci);
+	if (gsm->initiator)
+		gsm_dlci_begin_close(dlci);
 	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
 		tty_port_lower_dtr_rts(&dlci->port);
 	tty_port_close_end(&dlci->port, tty);
@@ -3035,10 +3038,12 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp)
 static void gsmtty_hangup(struct tty_struct *tty)
 {
 	struct gsm_dlci *dlci = tty->driver_data;
+	struct gsm_mux *gsm = dlci->gsm;
 	if (dlci->state == DLCI_CLOSED)
 		return;
 	tty_port_hangup(&dlci->port);
-	gsm_dlci_begin_close(dlci);
+	if (gsm->initiator)
+		gsm_dlci_begin_close(dlci);
 }
 
 static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
-- 
1.9.1


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

* Re: [PATCH v3] tty: n_gsm: delete DISC command frame as requester
  2021-07-05  2:28 [PATCH v3] tty: n_gsm: delete DISC command frame as requester Zhenguo Zhao
@ 2021-07-05  6:20 ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2021-07-05  6:20 UTC (permalink / raw)
  To: Zhenguo Zhao; +Cc: jirislaby, linux-kernel

On Mon, Jul 05, 2021 at 10:28:07AM +0800, Zhenguo Zhao wrote:
> From: Zhenguo Zhao <Zhenguo.Zhao1@unisoc.com>
> 
> as initiator,it need to send DISC command ,as requester,there is
> no need to send the DISC control frame,it will cause redundant data.
> 
> Signed-off-by: Zhenguo Zhao <Zhenguo.Zhao1@unisoc.com>
> ---
>  drivers/tty/n_gsm.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index 5fea02c..f8e5935 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -2050,7 +2050,8 @@ static int gsm_disconnect(struct gsm_mux *gsm)
>  	del_timer_sync(&gsm->t2_timer);
>  	/* Now we are sure T2 has stopped */
>  
> -	gsm_dlci_begin_close(dlci);
> +	if (gsm->initiator)
> +		gsm_dlci_begin_close(dlci);
>  	wait_event_interruptible(gsm->event,
>  				dlci->state == DLCI_CLOSED);
>  
> @@ -3014,6 +3015,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
>  static void gsmtty_close(struct tty_struct *tty, struct file *filp)
>  {
>  	struct gsm_dlci *dlci = tty->driver_data;
> +	struct gsm_mux *gsm = dlci->gsm;
>  
>  	if (dlci == NULL)
>  		return;
> @@ -3024,7 +3026,8 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp)
>  	mutex_unlock(&dlci->mutex);
>  	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
>  		return;
> -	gsm_dlci_begin_close(dlci);
> +	if (gsm->initiator)
> +		gsm_dlci_begin_close(dlci);
>  	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
>  		tty_port_lower_dtr_rts(&dlci->port);
>  	tty_port_close_end(&dlci->port, tty);
> @@ -3035,10 +3038,12 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp)
>  static void gsmtty_hangup(struct tty_struct *tty)
>  {
>  	struct gsm_dlci *dlci = tty->driver_data;
> +	struct gsm_mux *gsm = dlci->gsm;
>  	if (dlci->state == DLCI_CLOSED)
>  		return;
>  	tty_port_hangup(&dlci->port);
> -	gsm_dlci_begin_close(dlci);
> +	if (gsm->initiator)
> +		gsm_dlci_begin_close(dlci);
>  }
>  
>  static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
> -- 
> 1.9.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH v3] tty: n_gsm: delete DISC command frame as requester
  2021-07-05  2:28 [PATCH v3] tty: n_gsm: delete DISC command frame as requester Zhenguo Zhao
  2021-07-05  6:20 ` Greg KH
@ 2021-07-05  9:51 ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-05  6:58 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1625452087-12655-1-git-send-email-zhenguo6858@gmail.com>
References: <1625452087-12655-1-git-send-email-zhenguo6858@gmail.com>
TO: Zhenguo Zhao <zhenguo6858@gmail.com>
TO: zhenguo6858(a)gmail.com
TO: gregkh(a)linuxfoundation.org
TO: jirislaby(a)kernel.org
CC: linux-kernel(a)vger.kernel.org

Hi Zhenguo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on v5.13 next-20210701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Zhenguo-Zhao/tty-n_gsm-delete-DISC-command-frame-as-requester/20210705-102943
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
config: openrisc-randconfig-m031-20210705 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/tty/n_gsm.c:3023 gsmtty_close() warn: variable dereferenced before check 'dlci' (see line 3021)

vim +/dlci +3023 drivers/tty/n_gsm.c

e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3017  
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3018  static void gsmtty_close(struct tty_struct *tty, struct file *filp)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3019  {
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3020  	struct gsm_dlci *dlci = tty->driver_data;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05 @3021  	struct gsm_mux *gsm = dlci->gsm;
6ab8fba7fcb012 drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3022  
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26 @3023  	if (dlci == NULL)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3024  		return;
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3025  	if (dlci->state == DLCI_CLOSED)
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3026  		return;
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3027  	mutex_lock(&dlci->mutex);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3028  	gsm_destroy_network(dlci);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3029  	mutex_unlock(&dlci->mutex);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3030  	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3031  		return;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05  3032  	if (gsm->initiator)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3033  		gsm_dlci_begin_close(dlci);
d41861ca19c9e9 drivers/tty/n_gsm.c  Peter Hurley    2016-04-09  3034  	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
957dacaee56d18 drivers/tty/n_gsm.c  Johan Hovold    2013-03-07  3035  		tty_port_lower_dtr_rts(&dlci->port);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3036  	tty_port_close_end(&dlci->port, tty);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3037  	tty_port_tty_set(&dlci->port, NULL);
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3038  	return;
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3039  }
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3040  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 24258 bytes --]

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

* Re: [PATCH v3] tty: n_gsm: delete DISC command frame as requester
@ 2021-07-05  9:51 ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-07-05  9:51 UTC (permalink / raw)
  To: kbuild, Zhenguo Zhao, gregkh, jirislaby; +Cc: lkp, kbuild-all, linux-kernel

Hi Zhenguo,

url:    https://github.com/0day-ci/linux/commits/Zhenguo-Zhao/tty-n_gsm-delete-DISC-command-frame-as-requester/20210705-102943
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: openrisc-randconfig-m031-20210705 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/tty/n_gsm.c:3023 gsmtty_close() warn: variable dereferenced before check 'dlci' (see line 3021)

vim +/dlci +3023 drivers/tty/n_gsm.c

e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3018  static void gsmtty_close(struct tty_struct *tty, struct file *filp)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3019  {
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3020  	struct gsm_dlci *dlci = tty->driver_data;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05 @3021  	struct gsm_mux *gsm = dlci->gsm;
                                                                                              ^^^^^^^^^^
Dereferenced

6ab8fba7fcb012 drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3022  
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26 @3023  	if (dlci == NULL)
                                                                            ^^^^^^^^^^^^
Check is too late

e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3024  		return;
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3025  	if (dlci->state == DLCI_CLOSED)
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3026  		return;
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3027  	mutex_lock(&dlci->mutex);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3028  	gsm_destroy_network(dlci);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3029  	mutex_unlock(&dlci->mutex);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3030  	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3031  		return;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05  3032  	if (gsm->initiator)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3033  		gsm_dlci_begin_close(dlci);
d41861ca19c9e9 drivers/tty/n_gsm.c  Peter Hurley    2016-04-09  3034  	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
957dacaee56d18 drivers/tty/n_gsm.c  Johan Hovold    2013-03-07  3035  		tty_port_lower_dtr_rts(&dlci->port);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3036  	tty_port_close_end(&dlci->port, tty);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3037  	tty_port_tty_set(&dlci->port, NULL);
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3038  	return;
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3039  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


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

* Re: [PATCH v3] tty: n_gsm: delete DISC command frame as requester
@ 2021-07-05  9:51 ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-07-05  9:51 UTC (permalink / raw)
  To: kbuild-all

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

Hi Zhenguo,

url:    https://github.com/0day-ci/linux/commits/Zhenguo-Zhao/tty-n_gsm-delete-DISC-command-frame-as-requester/20210705-102943
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: openrisc-randconfig-m031-20210705 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/tty/n_gsm.c:3023 gsmtty_close() warn: variable dereferenced before check 'dlci' (see line 3021)

vim +/dlci +3023 drivers/tty/n_gsm.c

e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3018  static void gsmtty_close(struct tty_struct *tty, struct file *filp)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3019  {
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3020  	struct gsm_dlci *dlci = tty->driver_data;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05 @3021  	struct gsm_mux *gsm = dlci->gsm;
                                                                                              ^^^^^^^^^^
Dereferenced

6ab8fba7fcb012 drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3022  
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26 @3023  	if (dlci == NULL)
                                                                            ^^^^^^^^^^^^
Check is too late

e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3024  		return;
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3025  	if (dlci->state == DLCI_CLOSED)
4d9b109060f690 drivers/tty/n_gsm.c  Dirkjan Bussink 2013-01-30  3026  		return;
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3027  	mutex_lock(&dlci->mutex);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3028  	gsm_destroy_network(dlci);
bcd5abe28f40cc drivers/tty/n_gsm.c  Russ Gorby      2011-06-16  3029  	mutex_unlock(&dlci->mutex);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3030  	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3031  		return;
f72c4013b314ba drivers/tty/n_gsm.c  Zhenguo Zhao    2021-07-05  3032  	if (gsm->initiator)
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3033  		gsm_dlci_begin_close(dlci);
d41861ca19c9e9 drivers/tty/n_gsm.c  Peter Hurley    2016-04-09  3034  	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
957dacaee56d18 drivers/tty/n_gsm.c  Johan Hovold    2013-03-07  3035  		tty_port_lower_dtr_rts(&dlci->port);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3036  	tty_port_close_end(&dlci->port, tty);
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3037  	tty_port_tty_set(&dlci->port, NULL);
dfabf7ffa30585 drivers/tty/n_gsm.c  Chao Bi         2013-11-26  3038  	return;
e1eaea46bb4020 drivers/char/n_gsm.c Alan Cox        2010-03-26  3039  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

end of thread, other threads:[~2021-07-05  9:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05  2:28 [PATCH v3] tty: n_gsm: delete DISC command frame as requester Zhenguo Zhao
2021-07-05  6:20 ` Greg KH
2021-07-05  6:58 kernel test robot
2021-07-05  9:51 ` Dan Carpenter
2021-07-05  9:51 ` Dan Carpenter

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.