lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2cdef8d442bb5da39aed17bf994a800e768942f7.camel@perches.com>
Date:   Fri, 24 Jul 2020 14:29:39 -0700
From:   Joe Perches <joe@...ches.com>
To:     Wang Hai <wanghai38@...wei.com>, dchickles@...vell.com,
        sburla@...vell.com, fmanlunas@...vell.com, davem@...emloft.net,
        kuba@...nel.org
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] liquidio: Remove unneeded cast from memory
 allocation

On Fri, 2020-07-24 at 21:00 +0800, Wang Hai wrote:
> Remove casting the values returned by memory allocation function.
> 
> Coccinelle emits WARNING:
> 
> ./drivers/net/ethernet/cavium/liquidio/octeon_device.c:1155:14-36: WARNING:
>  casting value returned by memory allocation function to (struct octeon_dispatch *) is useless.
[]
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
[]
> @@ -1152,8 +1152,7 @@ octeon_register_dispatch_fn(struct octeon_device *oct,
>  
>  		dev_dbg(&oct->pci_dev->dev,
>  			"Adding opcode to dispatch list linked list\n");
> -		dispatch = (struct octeon_dispatch *)
> -			   vmalloc(sizeof(struct octeon_dispatch));
> +		dispatch = vmalloc(sizeof(struct octeon_dispatch));

More the question is why this is vmalloc at all
as the structure size is very small.

Likely this should just be kmalloc.

drivers/net/ethernet/cavium/liquidio/octeon_device.h:struct octeon_dispatch {
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   /** List head for this entry */
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   struct list_head list;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   /** The opcode for which the dispatch function & arg should be used */
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   u16 opcode;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   /** The function to be called for a packet received by the driver */
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   octeon_dispatch_fn_t dispatch_fn;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   /* The application specified argument to be passed to the above
drivers/net/ethernet/cavium/liquidio/octeon_device.h-    * function along with the received packet
drivers/net/ethernet/cavium/liquidio/octeon_device.h-    */
drivers/net/ethernet/cavium/liquidio/octeon_device.h-   void *arg;
drivers/net/ethernet/cavium/liquidio/octeon_device.h-}

>  		if (!dispatch) {
>  			dev_err(&oct->pci_dev->dev,
>  				"No memory to add dispatch function\n");

And this dev_err is unnecessary.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ