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:   Fri, 3 Mar 2017 10:41:25 -0800
From:   Laura Abbott <labbott@...hat.com>
To:     Hillf Danton <hillf.zj@...baba-inc.com>,
        'Sumit Semwal' <sumit.semwal@...aro.org>,
        'Riley Andrews' <riandrews@...roid.com>, arve@...roid.com
Cc:     romlem@...gle.com, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org, linaro-mm-sig@...ts.linaro.org,
        'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>,
        linux-arm-kernel@...ts.infradead.org, linux-media@...r.kernel.org,
        dri-devel@...ts.freedesktop.org,
        'Brian Starkey' <brian.starkey@....com>,
        'Daniel Vetter' <daniel.vetter@...el.com>,
        'Mark Brown' <broonie@...nel.org>,
        'Benjamin Gaignard' <benjamin.gaignard@...aro.org>,
        linux-mm@...ck.org
Subject: Re: [RFC PATCH 03/12] staging: android: ion: Duplicate sg_table

On 03/03/2017 12:18 AM, Hillf Danton wrote:
> 
> On March 03, 2017 5:45 AM Laura Abbott wrote: 
>>
>> +static struct sg_table *dup_sg_table(struct sg_table *table)
>> +{
>> +	struct sg_table *new_table;
>> +	int ret, i;
>> +	struct scatterlist *sg, *new_sg;
>> +
>> +	new_table = kzalloc(sizeof(*new_table), GFP_KERNEL);
>> +	if (!new_table)
>> +		return ERR_PTR(-ENOMEM);
>> +
>> +	ret = sg_alloc_table(new_table, table->nents, GFP_KERNEL);
>> +	if (ret) {
>> +		kfree(table);
> 
> Free new table?
> 
>> +		return ERR_PTR(-ENOMEM);
>> +	}
>> +
>> +	new_sg = new_table->sgl;
>> +	for_each_sg(table->sgl, sg, table->nents, i) {
>> +		memcpy(new_sg, sg, sizeof(*sg));
>> +		sg->dma_address = 0;
>> +		new_sg = sg_next(new_sg);
>> +	}
>> +
> 
> Do we need a helper, sg_copy_table(dst_table, src_table)?
> 
>> +	return new_table;
>> +}
>> +

Yes, that would probably be good since I've seen this
code elsewhere.

Thanks,
Laura

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ