Re: [PATCH v8 13/28] gunyah: rsc_mgr: Add RPC for sharing memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Elliot Berman <quic_eberman@xxxxxxxxxxx> [2022-12-19 14:58:34]:

> +static int _gh_rm_mem_append(struct gh_rm_rpc *rm, u32 mem_handle, bool end_append,
> +			struct gh_rm_mem_entry *mem_entries, size_t n_mem_entries)
> +{
> +	size_t msg_size = 0;
> +	void *msg;
> +	struct gh_mem_append_req_header *req_header;
> +	struct gh_mem_share_req_mem_section *mem_section;
> +	void *resp;
> +	size_t resp_size;
> +	int ret;
> +
> +	msg_size += sizeof(struct gh_mem_append_req_header);
> +	msg_size += offsetof(struct gh_mem_share_req_mem_section, entries[n_mem_entries]);
> +
> +	msg = kzalloc(msg_size, GFP_KERNEL);
> +	if (!msg)
> +		return -ENOMEM;
> +
> +	req_header = msg;
> +	mem_section = (void *)req_header + sizeof(struct gh_mem_append_req_header);
> +
> +	req_header->mem_handle = mem_handle;

cpu_to_le(mem_handle);


> +	if (end_append)
> +		req_header->flags |= GH_MEM_APPEND_REQ_FLAGS_END;
> +
> +	mem_section->n_entries = n_mem_entries;
> +	memcpy(mem_section->entries, mem_entries, sizeof(*mem_entries) * n_mem_entries);
> +
> +	ret = gh_rm_call(rm, GH_RM_RPC_MEM_APPEND, msg, msg_size, &resp, &resp_size);
> +	if (ret)

kfree(msg);

> +		return ret;
> +	kfree(resp);

kfree(msg);

> +
> +	return ret;
> +}
> +
> +static int gh_rm_mem_append(struct gh_rm_rpc *rm, u32 mem_handle, bool allow_append,

Is there any scenario where allow_append will be 'true'? As of this patch
atleast, its always 'false', so maybe just avoid this input argument?

> +static int gh_rm_mem_lend_common(struct gh_rm_rpc *rm, u32 message_id, struct gh_rm_mem_parcel *p)
> +{

[snip]

> +	acl_section->n_entries = p->n_acl_entries;

cpu_to_le32(p->n_acl_entries);

> +	memcpy(acl_section->entries, p->acl_entries, sizeof(*(p->acl_entries)) * p->n_acl_entries);
> +
> +	mem_section->n_entries = initial_n_mem_entries;

cpu_to_le32(initial_n_mem_entries);

> +	memcpy(mem_section->entries, p->mem_entries,
> +		sizeof(*(p->mem_entries)) * initial_n_mem_entries);
> +
> +	/* Set n_entries for memory attribute section to 0 */
> +	*mem_attr_section = 0;
> +
> +	ret = gh_rm_call(rm, message_id, msg, msg_size, &resp, &resp_size);
> +	if (ret)

kfree(msg)

> +		return ret;
> +
> +	if (resp_size != sizeof(__le32)) {
> +		ret = -EIO;
> +		goto out;
> +	}
> +
> +	p->mem_handle = le32_to_cpu(*(__le32 *)resp);
> +
> +	if (initial_n_mem_entries != p->n_mem_entries) {
> +		ret = gh_rm_mem_append(rm, p->mem_handle, false,
> +					&p->mem_entries[initial_n_mem_entries],
> +					p->n_mem_entries - initial_n_mem_entries);
> +		if (ret)
> +			gh_rm_mem_reclaim(rm, p);

			p->mem_handle = GH_MEM_HANDLE_INVAL in this case?

> +	}
> +
> +out:

kfree(msg) ?




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux