Re: [PATCH] serial: pch: Fix PCI device refcount leak in pch_request_dma()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andy,

Thanks for your reply !

On 2022/11/23 3:03, Andy Shevchenko wrote:
> On Tue, Nov 22, 2022 at 07:45:59PM +0800, Xiongfeng Wang wrote:
>> As comment of pci_get_slot() says, it returns a pci_device with its
>> refcount increased. The caller must decrement the reference count by
>> calling pci_dev_put().
> 
>> Since 'dma_dev' is only used to filter the channel in filter(), we can
>> call pci_dev_put() before exiting from pch_request_dma(). Add the
>> missing pci_dev_put() for the normal and error path.
> 
> No, we can't do that. How is it supposed to work if DMA device disappears in
> the middle?

When the DMA device is registered into the system, its refcount is increased.
dma_request_channel() will increase the refcount for 'dma_chan'. So I think this
can gurantee the DMA device not removed in the middle.

Thanks,
Xiongfeng

> 
> Look at how it's done in the
> 
> 5318f70da7e8 serial: 8250_lpss: Balance reference count for PCI DMA device
> 67ec6dd0b257 serial: 8250_mid: Balance reference count for PCI DMA device
> 



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux