RE: [PATCH] PCI: endpoint: functions: Use kmemdup instead of duplicating its function

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

 



Hi,

On 06 December 2018 10:21, Wen Yang wrote:
> kmemdup has implemented the function that kmalloc() + memcpy().
> We prefer to kmemdup rather than code opened implementation.
> 
> This issue was detected with the help of coccinelle.
> 
> Signed-off-by: Wen Yang <wen.yang99@xxxxxxxxxx>
> CC: Bob Copeland <me@xxxxxxxxxxxxxxx>
> 
> CC: Kishon Vijay Abraham I <kishon@xxxxxx>
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
> CC: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> CC: Gustavo Pimentel <gustavo.pimentel@xxxxxxxxxxxx>
> CC: Niklas Cassel <niklas.cassel@xxxxxxxx>
> CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> CC: Cyrille Pitchen <cyrille.pitchen@xxxxxxxxxxxxxxxxxx>
> CC: linux-pci@xxxxxxxxxxxxxxx (open list:PCI ENDPOINT SUBSYSTEM)
> CC: linux-kernel@xxxxxxxxxxxxxxx (open list)
> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 3e86fa3c7da3..6e42daa2a651 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -169,14 +169,12 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
>  		goto err_addr;
>  	}
> 
> -	buf = kzalloc(reg->size, GFP_KERNEL);
> +	buf = kzalloc(src_addr, reg->size, GFP_KERNEL);
Looks like a typo - kmemdup instead of kzalloc?

>  	if (!buf) {
>  		ret = -ENOMEM;
>  		goto err_map_addr;
>  	}
> 
> -	memcpy(buf, src_addr, reg->size);
> -
>  	crc32 = crc32_le(~0, buf, reg->size);
>  	if (crc32 != reg->checksum)
>  		ret = -EIO;
> --
> 2.19.1

Regards,
Alan





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux