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: <1333921246.2508.8.camel@joe2Laptop>
Date:	Sun, 08 Apr 2012 14:40:46 -0700
From:	Joe Perches <joe@...ches.com>
To:	Olof Johansson <olof@...om.net>
Cc:	Vinod Koul <vinod.koul@...el.com>,
	Dan Williams <dan.j.williams@...el.com>,
	linux-kernel@...r.kernel.org, Boojin Kim <boojin.kim@...sung.com>,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] dma: pl330: fix a couple of compilation warnings

On Sun, 2012-04-08 at 14:18 -0700, Olof Johansson wrote:
> Move a couple of tests and do a minor refactor to avoid:
[]
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
[]
> @@ -2926,8 +2928,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>  	INIT_LIST_HEAD(&pd->channels);
>  
>  	/* Initialize channel parameters */
> -	num_chan = max(pdat ? pdat->nr_valid_peri : (u8)pi->pcfg.num_peri,
> -			(u8)pi->pcfg.num_chan);
> +	num_chan = max_t(int, pdat ? pdat->nr_valid_peri :
> +				     pi->pcfg.num_peri,
> +			      pi->pcfg.num_chan);
>  	pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);

Few trivial things:

There's no error checking for a malloc failure
This should probably be kcalloc
The alignment here is not nice

Maybe:

	num_chan = max_t(size_t, pdat ? pdat->nr_valid_peri : pi->pcfg.num_peri,
			 pi->pcfg.num_chan);
	pdmac->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL);
	if (!pdmac->peripherals)
		goto some_err;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ