mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 王擎 <wangqing@vivo.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] tty: serial: add missing pci_dev_put() before return
Date: Tue, 15 Feb 2022 08:41:18 +0000	[thread overview]
Message-ID: <SL2PR06MB30825B984106703CF463791DBD349@SL2PR06MB3082.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <AEkAWQDgE7ilYE2UlPdbG4pX.9.1644911172685.Hmail.wangqing@vivo.com.@PFlndGFPMGFTTkxXMGRWRlpAa3JvYWguY29tPg==>


>>On Mon, Feb 14, 2022 at 06:01:12PM -0800, Qing Wang wrote:
>> From: Wang Qing <wangqing@vivo.com>
>> 
>> pci_get_slot() increases its reference count, the caller must
>> decrement the reference count by calling pci_dev_put()
>> 
>> Signed-off-by: Wang Qing <wangqing@vivo.com>
>> ---
>>  drivers/tty/serial/pch_uart.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
>> index f0351e6..da5a276
>> --- a/drivers/tty/serial/pch_uart.c
>> +++ b/drivers/tty/serial/pch_uart.c
>> @@ -723,7 +723,7 @@ static void pch_request_dma(struct uart_port *port)
>>        if (!chan) {
>>                dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Tx)\n",
>>                        __func__);
>> -             return;
>> +             goto out;
>>        }
>>        priv->chan_tx = chan;
>>  
>> @@ -739,13 +739,16 @@ static void pch_request_dma(struct uart_port *port)
>>                        __func__);
>>                dma_release_channel(priv->chan_tx);
>>                priv->chan_tx = NULL;
>> -             return;
>> +             goto out;
>>        }
>>  
>>        /* Get Consistent memory for DMA */
>>        priv->rx_buf_virt = dma_alloc_coherent(port->dev, port->fifosize,
>>                                    &priv->rx_buf_dma, GFP_KERNEL);
>>        priv->chan_rx = chan;
>> +
>> +out:
>> +     pci_dev_put(dma_dev);
>>  }
>>  
>>  static void pch_dma_rx_complete(void *arg)
>> -- 
>> 2.7.4
>> 
>
>What tool are you using to find these?  As Jiri points out, it is not
>very correct at all, be careful to not cause bugs when you are
>attempting to fix them.
>
>For stuff like this, please always test your changes to verify they
>work.

Got it. 

Some tools are taken from the cocci community, some are developed byself, 
I will improve the tool and add tests to avoid this situation.

Thanks,
Qing
>
>thanks,
>
>greg k-h
>

      parent reply	other threads:[~2022-02-15  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15  2:01 Qing Wang
2022-02-15  6:14 ` Jiri Slaby
2022-02-15  7:46 ` Greg Kroah-Hartman
     [not found] ` <AEkAWQDgE7ilYE2UlPdbG4pX.9.1644911172685.Hmail.wangqing@vivo.com.@PFlndGFPMGFTTkxXMGRWRlpAa3JvYWguY29tPg==>
2022-02-15  8:41   ` 王擎 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SL2PR06MB30825B984106703CF463791DBD349@SL2PR06MB3082.apcprd06.prod.outlook.com \
    --to=wangqing@vivo.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®