All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tty: rpmsg: Fix race condition releasing tty port
@ 2021-12-15 15:31 Arnaud Pouliquen
  2021-12-21  8:18 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaud Pouliquen @ 2021-12-15 15:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Bjorn Andersson, Mathieu Poirier, linux-remoteproc, linux-kernel,
	linux-stm32, arnaud.pouliquen

The tty_port struct is part of the rpmsg_tty_port structure.
The issue is that the rpmsg_tty_port structure is freed on
rpmsg_tty_remove while it is still referenced in the tty_struct.
Its release is not predictable due to workqueues.

For instance following ftrace shows that rpmsg_tty_close is called after
rpmsg_tty_release_cport:

     nr_test.sh-389     [000] .....   212.093752: rpmsg_tty_remove <-rpmsg_dev_
remove
             cat-1191    [001] .....   212.095697: tty_release <-__fput
      nr_test.sh-389     [000] .....   212.099166: rpmsg_tty_release_cport <-rpm
sg_tty_remove
             cat-1191    [001] .....   212.115352: rpmsg_tty_close <-tty_release
             cat-1191    [001] .....   212.115371: release_tty <-tty_release_str

As consequence, the port must be free only when user has released the TTY
interface.

This path :
- Introduce the .destruct port ops function to release the allocated
  rpmsg_tty_port structure.
- Manages the tty port refcounting to trig the .destruct port ops,
- Introduces the rpmsg_tty_cleanup function to ensure that the TTY is
  removed before decreasing the port refcount.
- Uses tty_vhangup and tty_port_hangup instead of tty_port_tty_hangup.

Fixes: 7c0408d80579 ("tty: add rpmsg driver")
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
delta vs V2: taking into account Jiri Slaby's comments:
 - Inline rpmsg_tty_release_cport in rpmsg_tty_destruct_port,
 - call tty_port_put in case of error in rpmsg_tty_probe,
 - use tty_port_get port return in rpmsg_tty_install to take into account
   NULL port return case.

Applied and tested on fa55b7dcdc43 ("Linux 5.16-rc1", 2021-11-14)
---
 drivers/tty/rpmsg_tty.c | 49 +++++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c
index dae2a4e44f38..cdc590c63f03 100644
--- a/drivers/tty/rpmsg_tty.c
+++ b/drivers/tty/rpmsg_tty.c
@@ -50,10 +50,21 @@ static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len, void *p
 static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty)
 {
 	struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index);
+	struct tty_port *port = tty->port;
 
 	tty->driver_data = cport;
 
-	return tty_port_install(&cport->port, driver, tty);
+	port = tty_port_get(&cport->port);
+	return tty_port_install(port, driver, tty);
+}
+
+static void rpmsg_tty_cleanup(struct tty_struct *tty)
+{
+	struct tty_port *port = tty->port;
+
+	WARN_ON(!port);
+
+	tty_port_put(port);
 }
 
 static int rpmsg_tty_open(struct tty_struct *tty, struct file *filp)
@@ -106,12 +117,19 @@ static unsigned int rpmsg_tty_write_room(struct tty_struct *tty)
 	return size;
 }
 
+static void rpmsg_tty_hangup(struct tty_struct *tty)
+{
+	tty_port_hangup(tty->port);
+}
+
 static const struct tty_operations rpmsg_tty_ops = {
 	.install	= rpmsg_tty_install,
 	.open		= rpmsg_tty_open,
 	.close		= rpmsg_tty_close,
 	.write		= rpmsg_tty_write,
 	.write_room	= rpmsg_tty_write_room,
+	.hangup		= rpmsg_tty_hangup,
+	.cleanup	= rpmsg_tty_cleanup,
 };
 
 static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void)
@@ -137,8 +155,10 @@ static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void)
 	return cport;
 }
 
-static void rpmsg_tty_release_cport(struct rpmsg_tty_port *cport)
+static void rpmsg_tty_destruct_port(struct tty_port *port)
 {
+	struct rpmsg_tty_port *cport = container_of(port, struct rpmsg_tty_port, port);
+
 	mutex_lock(&idr_lock);
 	idr_remove(&tty_idr, cport->id);
 	mutex_unlock(&idr_lock);
@@ -146,7 +166,10 @@ static void rpmsg_tty_release_cport(struct rpmsg_tty_port *cport)
 	kfree(cport);
 }
 
-static const struct tty_port_operations rpmsg_tty_port_ops = { };
+static const struct tty_port_operations rpmsg_tty_port_ops = {
+	.destruct = rpmsg_tty_destruct_port,
+};
+
 
 static int rpmsg_tty_probe(struct rpmsg_device *rpdev)
 {
@@ -166,7 +189,8 @@ static int rpmsg_tty_probe(struct rpmsg_device *rpdev)
 					   cport->id, dev);
 	if (IS_ERR(tty_dev)) {
 		ret = dev_err_probe(dev, PTR_ERR(tty_dev), "Failed to register tty port\n");
-		goto err_destroy;
+		tty_port_put(&cport->port);
+		return ret;
 	}
 
 	cport->rpdev = rpdev;
@@ -177,28 +201,25 @@ static int rpmsg_tty_probe(struct rpmsg_device *rpdev)
 		rpdev->src, rpdev->dst, cport->id);
 
 	return 0;
-
-err_destroy:
-	tty_port_destroy(&cport->port);
-	rpmsg_tty_release_cport(cport);
-
-	return ret;
 }
 
 static void rpmsg_tty_remove(struct rpmsg_device *rpdev)
 {
 	struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev);
+	struct tty_struct *tty;
 
 	dev_dbg(&rpdev->dev, "Removing rpmsg tty device %d\n", cport->id);
 
 	/* User hang up to release the tty */
-	if (tty_port_initialized(&cport->port))
-		tty_port_tty_hangup(&cport->port, false);
+	tty = tty_port_tty_get(&cport->port);
+	if (tty) {
+		tty_vhangup(tty);
+		tty_kref_put(tty);
+	}
 
 	tty_unregister_device(rpmsg_tty_driver, cport->id);
 
-	tty_port_destroy(&cport->port);
-	rpmsg_tty_release_cport(cport);
+	tty_port_put(&cport->port);
 }
 
 static struct rpmsg_device_id rpmsg_driver_tty_id_table[] = {
-- 
2.17.1


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

* Re: [PATCH v3] tty: rpmsg: Fix race condition releasing tty port
  2021-12-15 15:31 [PATCH v3] tty: rpmsg: Fix race condition releasing tty port Arnaud Pouliquen
@ 2021-12-21  8:18 ` Greg Kroah-Hartman
  2021-12-21 14:18   ` Arnaud POULIQUEN
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-12-21  8:18 UTC (permalink / raw)
  To: Arnaud Pouliquen
  Cc: Jiri Slaby, Bjorn Andersson, Mathieu Poirier, linux-remoteproc,
	linux-kernel, linux-stm32

On Wed, Dec 15, 2021 at 04:31:21PM +0100, Arnaud Pouliquen wrote:
> The tty_port struct is part of the rpmsg_tty_port structure.
> The issue is that the rpmsg_tty_port structure is freed on
> rpmsg_tty_remove while it is still referenced in the tty_struct.
> Its release is not predictable due to workqueues.
> 
> For instance following ftrace shows that rpmsg_tty_close is called after
> rpmsg_tty_release_cport:
> 
>      nr_test.sh-389     [000] .....   212.093752: rpmsg_tty_remove <-rpmsg_dev_
> remove
>              cat-1191    [001] .....   212.095697: tty_release <-__fput
>       nr_test.sh-389     [000] .....   212.099166: rpmsg_tty_release_cport <-rpm
> sg_tty_remove
>              cat-1191    [001] .....   212.115352: rpmsg_tty_close <-tty_release
>              cat-1191    [001] .....   212.115371: release_tty <-tty_release_str
> 
> As consequence, the port must be free only when user has released the TTY
> interface.
> 
> This path :
> - Introduce the .destruct port ops function to release the allocated
>   rpmsg_tty_port structure.
> - Manages the tty port refcounting to trig the .destruct port ops,
> - Introduces the rpmsg_tty_cleanup function to ensure that the TTY is
>   removed before decreasing the port refcount.
> - Uses tty_vhangup and tty_port_hangup instead of tty_port_tty_hangup.

Shouldn't this hangup change be a separate change?

> 
> Fixes: 7c0408d80579 ("tty: add rpmsg driver")
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
> ---
> delta vs V2: taking into account Jiri Slaby's comments:
>  - Inline rpmsg_tty_release_cport in rpmsg_tty_destruct_port,
>  - call tty_port_put in case of error in rpmsg_tty_probe,
>  - use tty_port_get port return in rpmsg_tty_install to take into account
>    NULL port return case.
> 
> Applied and tested on fa55b7dcdc43 ("Linux 5.16-rc1", 2021-11-14)
> ---
>  drivers/tty/rpmsg_tty.c | 49 +++++++++++++++++++++++++++++------------
>  1 file changed, 35 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c
> index dae2a4e44f38..cdc590c63f03 100644
> --- a/drivers/tty/rpmsg_tty.c
> +++ b/drivers/tty/rpmsg_tty.c
> @@ -50,10 +50,21 @@ static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len, void *p
>  static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty)
>  {
>  	struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index);
> +	struct tty_port *port = tty->port;
>  
>  	tty->driver_data = cport;
>  
> -	return tty_port_install(&cport->port, driver, tty);
> +	port = tty_port_get(&cport->port);
> +	return tty_port_install(port, driver, tty);
> +}
> +
> +static void rpmsg_tty_cleanup(struct tty_struct *tty)
> +{
> +	struct tty_port *port = tty->port;
> +
> +	WARN_ON(!port);

How can this ever trigger?  Shouldn't you do something if it can?

thanks,

greg k-h

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

* Re: [PATCH v3] tty: rpmsg: Fix race condition releasing tty port
  2021-12-21  8:18 ` Greg Kroah-Hartman
@ 2021-12-21 14:18   ` Arnaud POULIQUEN
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaud POULIQUEN @ 2021-12-21 14:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Bjorn Andersson, Mathieu Poirier, linux-remoteproc,
	linux-kernel, linux-stm32

Hello Greg,


On 12/21/21 9:18 AM, Greg Kroah-Hartman wrote:
> On Wed, Dec 15, 2021 at 04:31:21PM +0100, Arnaud Pouliquen wrote:
>> The tty_port struct is part of the rpmsg_tty_port structure.
>> The issue is that the rpmsg_tty_port structure is freed on
>> rpmsg_tty_remove while it is still referenced in the tty_struct.
>> Its release is not predictable due to workqueues.
>>
>> For instance following ftrace shows that rpmsg_tty_close is called after
>> rpmsg_tty_release_cport:
>>
>>      nr_test.sh-389     [000] .....   212.093752: rpmsg_tty_remove <-rpmsg_dev_
>> remove
>>              cat-1191    [001] .....   212.095697: tty_release <-__fput
>>       nr_test.sh-389     [000] .....   212.099166: rpmsg_tty_release_cport <-rpm
>> sg_tty_remove
>>              cat-1191    [001] .....   212.115352: rpmsg_tty_close <-tty_release
>>              cat-1191    [001] .....   212.115371: release_tty <-tty_release_str
>>
>> As consequence, the port must be free only when user has released the TTY
>> interface.
>>
>> This path :
>> - Introduce the .destruct port ops function to release the allocated
>>   rpmsg_tty_port structure.
>> - Manages the tty port refcounting to trig the .destruct port ops,
>> - Introduces the rpmsg_tty_cleanup function to ensure that the TTY is
>>   removed before decreasing the port refcount.
>> - Uses tty_vhangup and tty_port_hangup instead of tty_port_tty_hangup.
> 
> Shouldn't this hangup change be a separate change?

Thanks for pointing this!

My first answer was that this is part of the fix to make the hangup synchronous.
But making more tests I'm not able to reproduce the reproduce the race issue
using tty_port_tty_hangup.

I don't master enough the TTY framework to know if using tty_vhangup is safer...
The difference between tty_vhangup and tty_hangup seems only that __tty_hangup
is directly called in tty_vhangup while a work is created in tty_hangup.

But after that tty_kref_put calls queue_release_one_tty making the rest of the
release asynchronous. And this last part of the release is the cause of the race
condition i observed.

So i propose to just drop this part and keep the use of tty_port_tty_hangup.

The alternative is to add it in a separate patch as you propose. But from now I
have not more rational.

Any advice is welcome!

> 
>>
>> Fixes: 7c0408d80579 ("tty: add rpmsg driver")
>> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
>> ---
>> delta vs V2: taking into account Jiri Slaby's comments:
>>  - Inline rpmsg_tty_release_cport in rpmsg_tty_destruct_port,
>>  - call tty_port_put in case of error in rpmsg_tty_probe,
>>  - use tty_port_get port return in rpmsg_tty_install to take into account
>>    NULL port return case.
>>
>> Applied and tested on fa55b7dcdc43 ("Linux 5.16-rc1", 2021-11-14)
>> ---
>>  drivers/tty/rpmsg_tty.c | 49 +++++++++++++++++++++++++++++------------
>>  1 file changed, 35 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c
>> index dae2a4e44f38..cdc590c63f03 100644
>> --- a/drivers/tty/rpmsg_tty.c
>> +++ b/drivers/tty/rpmsg_tty.c
>> @@ -50,10 +50,21 @@ static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len, void *p
>>  static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty)
>>  {
>>  	struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index);
>> +	struct tty_port *port = tty->port;
>>  
>>  	tty->driver_data = cport;
>>  
>> -	return tty_port_install(&cport->port, driver, tty);
>> +	port = tty_port_get(&cport->port);
>> +	return tty_port_install(port, driver, tty);
>> +}
>> +
>> +static void rpmsg_tty_cleanup(struct tty_struct *tty)
>> +{
>> +	struct tty_port *port = tty->port;
>> +
>> +	WARN_ON(!port);
> 
> How can this ever trigger?  Shouldn't you do something if it can?

Over-protection i will suppress it.

Thanks and Regards,
Arnaud

> 
> thanks,
> 
> greg k-h
> 

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

* Re: [PATCH v3] tty: rpmsg: Fix race condition releasing tty port
@ 2022-01-02 15:30 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-02 15:30 UTC (permalink / raw)
  To: kbuild

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

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211215153121.30010-1-arnaud.pouliquen@foss.st.com>
References: <20211215153121.30010-1-arnaud.pouliquen@foss.st.com>
TO: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
TO: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
TO: Jiri Slaby <jirislaby@kernel.org>
CC: Bjorn Andersson <bjorn.andersson@linaro.org>
CC: Mathieu Poirier <mathieu.poirier@linaro.org>
CC: linux-remoteproc(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
CC: linux-stm32(a)st-md-mailman.stormreply.com
CC: arnaud.pouliquen(a)foss.st.com

Hi Arnaud,

I love your patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on linux/master linus/master v5.16-rc7 next-20211224]
[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/Arnaud-Pouliquen/tty-rpmsg-Fix-race-condition-releasing-tty-port/20211215-235006
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: riscv-randconfig-c006-20211226 (https://download.01.org/0day-ci/archive/20220102/202201022353.FgGnJg5A-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a9e8b1ee7fd44b53c555a7823ae8fd1a8209c520)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/827a192629877cd67f12b906fb467d46f3526db5
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arnaud-Pouliquen/tty-rpmsg-Fix-race-condition-releasing-tty-port/20211215-235006
        git checkout 827a192629877cd67f12b906fb467d46f3526db5
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   drivers/misc/fastrpc.c:459:6: note: Assuming field 'nscalars' is not equal to 0
           if (ctx->nscalars) {
               ^~~~~~~~~~~~~
   drivers/misc/fastrpc.c:459:2: note: Taking true branch
           if (ctx->nscalars) {
           ^
   drivers/misc/fastrpc.c:460:15: note: Calling 'kcalloc'
                   ctx->maps = kcalloc(ctx->nscalars,
                               ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:9: note: Calling 'kmalloc_array'
           return kmalloc_array(n, size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:626:2: note: Taking false branch
           if (unlikely(check_mul_overflow(n, size, &bytes)))
           ^
   include/linux/slab.h:628:30: note: Left side of '&&' is false
           if (__builtin_constant_p(n) && __builtin_constant_p(size))
                                       ^
   include/linux/slab.h:630:2: note: Returning pointer, which participates in a condition later
           return __kmalloc(bytes, flags);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:9: note: Returning from 'kmalloc_array'
           return kmalloc_array(n, size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:2: note: Returning pointer, which participates in a condition later
           return kmalloc_array(n, size, flags | __GFP_ZERO);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:460:15: note: Returning from 'kcalloc'
                   ctx->maps = kcalloc(ctx->nscalars,
                               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:462:7: note: Assuming field 'maps' is non-null
                   if (!ctx->maps) {
                       ^~~~~~~~~~
   drivers/misc/fastrpc.c:462:3: note: Taking false branch
                   if (!ctx->maps) {
                   ^
   drivers/misc/fastrpc.c:466:16: note: Calling 'kcalloc'
                   ctx->olaps = kcalloc(ctx->nscalars,
                                ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:9: note: Calling 'kmalloc_array'
           return kmalloc_array(n, size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:626:2: note: Taking false branch
           if (unlikely(check_mul_overflow(n, size, &bytes)))
           ^
   include/linux/slab.h:628:30: note: Left side of '&&' is false
           if (__builtin_constant_p(n) && __builtin_constant_p(size))
                                       ^
   include/linux/slab.h:630:2: note: Returning pointer, which participates in a condition later
           return __kmalloc(bytes, flags);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:9: note: Returning from 'kmalloc_array'
           return kmalloc_array(n, size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:661:2: note: Returning pointer, which participates in a condition later
           return kmalloc_array(n, size, flags | __GFP_ZERO);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:466:16: note: Returning from 'kcalloc'
                   ctx->olaps = kcalloc(ctx->nscalars,
                                ^~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:468:7: note: Assuming field 'olaps' is non-null
                   if (!ctx->olaps) {
                       ^~~~~~~~~~~
   drivers/misc/fastrpc.c:468:3: note: Taking false branch
                   if (!ctx->olaps) {
                   ^
   drivers/misc/fastrpc.c:473:3: note: Null pointer value stored to field 'args'
                   ctx->args = args;
                   ^~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:474:3: note: Calling 'fastrpc_get_buff_overlaps'
                   fastrpc_get_buff_overlaps(ctx);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:409:14: note: Assuming 'i' is < field 'nbufs'
           for (i = 0; i < ctx->nbufs; ++i) {
                       ^~~~~~~~~~~~~~
   drivers/misc/fastrpc.c:409:2: note: Loop condition is true.  Entering loop body
           for (i = 0; i < ctx->nbufs; ++i) {
           ^
   drivers/misc/fastrpc.c:410:25: note: Dereference of null pointer
                   ctx->olaps[i].start = ctx->args[i].ptr;
                                         ^~~~~~~~~~~~~~~~
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
>> drivers/tty/rpmsg_tty.c:53:19: warning: Value stored to 'port' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct tty_port *port = tty->port;
                            ^~~~   ~~~~~~~~~
   drivers/tty/rpmsg_tty.c:53:19: note: Value stored to 'port' during its initialization is never read
           struct tty_port *port = tty->port;
                            ^~~~   ~~~~~~~~~
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (7 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   drivers/firewire/core-cdev.c:611:2: warning: 7th function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
           fw_send_request(client->device->card, &e->r.transaction,
           ^
   drivers/firewire/core-cdev.c:1481:6: note: Assuming field 'speed' is <= field 'link_speed'
           if (a->speed > client->device->card->link_speed ||
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/firewire/core-cdev.c:1481:6: note: Left side of '||' is false
   drivers/firewire/core-cdev.c:1482:6: note: Assuming the condition is false
               a->length > 1024 << a->speed)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/firewire/core-cdev.c:1481:2: note: Taking false branch
           if (a->speed > client->device->card->link_speed ||
           ^
   drivers/firewire/core-cdev.c:1485:6: note: Assuming field 'tag' is <= 3
           if (a->tag > 3 || a->channel > 63 || a->sy > 15)
               ^~~~~~~~~~
   drivers/firewire/core-cdev.c:1485:6: note: Left side of '||' is false
   drivers/firewire/core-cdev.c:1485:20: note: Assuming field 'channel' is <= 63
           if (a->tag > 3 || a->channel > 63 || a->sy > 15)
                             ^~~~~~~~~~~~~~~
   drivers/firewire/core-cdev.c:1485:6: note: Left side of '||' is false
           if (a->tag > 3 || a->channel > 63 || a->sy > 15)
               ^
   drivers/firewire/core-cdev.c:1485:39: note: Assuming field 'sy' is <= 15
           if (a->tag > 3 || a->channel > 63 || a->sy > 15)
                                                ^~~~~~~~~~
   drivers/firewire/core-cdev.c:1485:2: note: Taking false branch
           if (a->tag > 3 || a->channel > 63 || a->sy > 15)
           ^
   drivers/firewire/core-cdev.c:1495:9: note: Calling 'init_request'
           return init_request(client, &request, dest, a->speed);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/firewire/core-cdev.c:583:15: note: Field 'tcode' is equal to TCODE_STREAM_DATA
           if (request->tcode != TCODE_STREAM_DATA &&
                        ^
   drivers/firewire/core-cdev.c:583:42: note: Left side of '&&' is false
           if (request->tcode != TCODE_STREAM_DATA &&
                                                   ^
   drivers/firewire/core-cdev.c:587:15: note: Field 'tcode' is not equal to TCODE_WRITE_QUADLET_REQUEST
           if (request->tcode == TCODE_WRITE_QUADLET_REQUEST &&
                        ^
   drivers/firewire/core-cdev.c:587:52: note: Left side of '&&' is false
           if (request->tcode == TCODE_WRITE_QUADLET_REQUEST &&
                                                             ^
   drivers/firewire/core-cdev.c:592:6: note: Assuming 'e' is not equal to NULL
           if (e == NULL)
               ^~~~~~~~~
   drivers/firewire/core-cdev.c:592:2: note: Taking false branch
           if (e == NULL)
           ^

vim +/port +53 drivers/tty/rpmsg_tty.c

7c0408d8057971 Arnaud Pouliquen 2021-10-15  49  
7c0408d8057971 Arnaud Pouliquen 2021-10-15  50  static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty)
7c0408d8057971 Arnaud Pouliquen 2021-10-15  51  {
7c0408d8057971 Arnaud Pouliquen 2021-10-15  52  	struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index);
827a192629877c Arnaud Pouliquen 2021-12-15 @53  	struct tty_port *port = tty->port;
7c0408d8057971 Arnaud Pouliquen 2021-10-15  54  
7c0408d8057971 Arnaud Pouliquen 2021-10-15  55  	tty->driver_data = cport;
7c0408d8057971 Arnaud Pouliquen 2021-10-15  56  
827a192629877c Arnaud Pouliquen 2021-12-15  57  	port = tty_port_get(&cport->port);
827a192629877c Arnaud Pouliquen 2021-12-15  58  	return tty_port_install(port, driver, tty);
827a192629877c Arnaud Pouliquen 2021-12-15  59  }
827a192629877c Arnaud Pouliquen 2021-12-15  60  

---
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] 4+ messages in thread

end of thread, other threads:[~2022-01-02 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 15:31 [PATCH v3] tty: rpmsg: Fix race condition releasing tty port Arnaud Pouliquen
2021-12-21  8:18 ` Greg Kroah-Hartman
2021-12-21 14:18   ` Arnaud POULIQUEN
2022-01-02 15:30 kernel test robot

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.