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] [day] [month] [year] [list]
Message-ID: <20170818004311.GB1996@intel.com>
Date:   Fri, 18 Aug 2017 08:43:11 +0800
From:   Aaron Lu <aaron.lu@...el.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm <linux-mm@...ck.org>, lkml <linux-kernel@...r.kernel.org>,
        "Chen, Tim C" <tim.c.chen@...el.com>,
        Huang Ying <ying.huang@...el.com>,
        "Kleen, Andi" <andi.kleen@...el.com>,
        Michal Hocko <mhocko@...e.com>,
        Minchan Kim <minchan@...nel.org>,
        Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH v2] swap: choose swap device according to numa node

On Thu, Aug 17, 2017 at 03:44:08PM -0700, Andrew Morton wrote:
> On Wed, 16 Aug 2017 10:44:40 +0800 Aaron Lu <aaron.lu@...el.com> wrote:
> > ...
> >
> > +static int __init swapfile_init(void)
> > +{
> > +	int nid;
> > +
> > +	swap_avail_heads = kmalloc(nr_node_ids * sizeof(struct plist_head), GFP_KERNEL);
> 
> I suppose we should use kmalloc_array(), as someone wrote it for us.
> 
> --- a/mm/swapfile.c~swap-choose-swap-device-according-to-numa-node-v2-fix
> +++ a/mm/swapfile.c
> @@ -3700,7 +3700,8 @@ static int __init swapfile_init(void)
>  {
>  	int nid;
>  
> -	swap_avail_heads = kmalloc(nr_node_ids * sizeof(struct plist_head), GFP_KERNEL);
> +	swap_avail_heads = kmalloc_array(nr_node_ids, sizeof(struct plist_head),
> +					 GFP_KERNEL);
>  	if (!swap_avail_heads) {
>  		pr_emerg("Not enough memory for swap heads, swap is disabled\n");
>  		return -ENOMEM;
> 
> > +	if (!swap_avail_heads) {
> > +		pr_emerg("Not enough memory for swap heads, swap is disabled\n");
> 
> checkpatch tells us that the "Not enough memory" is a bit redundant, as
> the memory allocator would have already warned.  So it's sufficient to
> additionally say only "swap is disabled" here.  But it's hardly worth
> changing.

Thanks Andrew for taking care of this.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ