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: <be27a31c-6c63-43cd-9857-f4b2a9568cf6@quicinc.com>
Date:   Thu, 28 Sep 2023 11:19:34 -0700
From:   Jeff Johnson <quic_jjohnson@...cinc.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>,
        Andy Gross <agross@...nel.org>,
        "Bjorn Andersson" <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Maximilian Luz <luzmaximilian@...il.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
CC:     <linux-kernel@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>,
        <kernel@...cinc.com>,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v2 02/11] firmware: qcom: scm: add a dedicated SCM memory
 allocator

On 9/28/2023 2:20 AM, Bartosz Golaszewski wrote:
> +void *qcom_scm_mem_alloc(size_t size, gfp_t gfp)
> +{
> +	struct qcom_scm_mem_chunk *chunk;
> +	unsigned long vaddr;

there are places below where you unnecessarily typecast this to its 
given type

> +	int ret;
> +
> +	if (!size)
> +		return ZERO_SIZE_PTR;
> +
> +	size = roundup(size, 1 << PAGE_SHIFT);
> +
> +	chunk = kzalloc(sizeof(*chunk), gfp);
> +	if (!chunk)
> +		return NULL;
> +
> +	vaddr = gen_pool_alloc(qcom_scm_mem.pool, size);
> +	if (!vaddr) {
> +		kfree(chunk);
> +		return NULL;
> +	}
> +
> +	chunk->paddr = gen_pool_virt_to_phys(qcom_scm_mem.pool,
> +					     (unsigned long)vaddr);

unnecessary typecast?

> +	chunk->size = size;
> +
> +	scoped_guard(spinlock_irqsave, &qcom_scm_mem.lock) {

my first exposure to this infrastructure..very cool now that I've 
wrapped my head around it! This helped for those also new to this:
https://lwn.net/Articles/934679/

> +		ret = radix_tree_insert(&qcom_scm_mem.chunks, vaddr, chunk);
> +		if (ret) {
> +			gen_pool_free(qcom_scm_mem.pool, (unsigned long)vaddr,

unnecessary typecast?

> +				      chunk->size);
> +			kfree(chunk);
> +			return NULL;
> +		}
> +	}
> +
> +	return (void *)vaddr;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ