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]
Date:   Thu, 8 Dec 2022 09:26:35 +0100
From:   Michal Kubecek <mkubecek@...e.cz>
To:     Jesse Brandeburg <jesse.brandeburg@...el.com>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH ethtool v2 02/13] ethtool: fix trivial issue in allocation

On Wed, Dec 07, 2022 at 05:11:11PM -0800, Jesse Brandeburg wrote:
> Fix the following warning by changing the type being multiplied by to
> the type being assigned to.
> 
> Description: Result of 'calloc' is converted to a pointer of type
> 'unsigned long', which is incompatible with sizeof operand type 'long'
> File: /home/jbrandeb/git/ethtool/rxclass.c
> Line: 527
> 
> Fixes: 5a3279e43f2b ("rxclass: Replace global rmgr with automatic variable/parameter")
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@...el.com>
> ---
>  rxclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rxclass.c b/rxclass.c
> index 6cf81fdafc85..ebdd97960e5b 100644
> --- a/rxclass.c
> +++ b/rxclass.c
> @@ -524,7 +524,7 @@ static int rmgr_init(struct cmd_context *ctx, struct rmgr_ctrl *rmgr)
>  	}
>  
>  	/* initialize bitmap for storage of valid locations */
> -	rmgr->slot = calloc(1, BITS_TO_LONGS(rmgr->size) * sizeof(long));
> +	rmgr->slot = calloc(1, BITS_TO_LONGS(rmgr->size) * sizeof(unsigned long));

While at it, maybe we should take the cleanup one step further and use
sizeof(*rmgr->slot) or sizeof(rmgr->slot[0]) instead. And perhaps it
would also make sense to follow the logic of calloc() arguments and use

	calloc(BITS_TO_LONGS(rmgr->size), sizeof(rmgr->slot[0]))

Michal


>  	if (!rmgr->slot) {
>  		perror("rmgr: Cannot allocate memory for RX class rules");
>  		return -1;
> -- 
> 2.31.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ