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:   Mon, 19 Aug 2019 12:54:04 +0800
From:   "Zhao, Yakui" <yakui.zhao@...el.com>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
        Yin FengWei <fengwei.yin@...el.com>,
        Jason Chen CJ <jason.cj.chen@...el.com>,
        Liu Shuo <shuo.a.liu@...el.com>
Subject: Re: [RFC PATCH 11/15] drivers/acrn: add the support of handling
 emulated ioreq



On 2019年08月16日 21:39, Dan Carpenter wrote:
> On Fri, Aug 16, 2019 at 10:25:52AM +0800, Zhao Yakui wrote:
>> +int acrn_ioreq_create_client(unsigned short vmid,
>> +			     ioreq_handler_t handler,
>> +			     void *client_priv,
>> +			     char *name)
>> +{
>> +	struct acrn_vm *vm;
>> +	struct ioreq_client *client;
>> +	int client_id;
>> +
>> +	might_sleep();
>> +
>> +	vm = find_get_vm(vmid);
>> +	if (unlikely(!vm || !vm->req_buf)) {
>> +		pr_err("acrn-ioreq: failed to find vm from vmid %d\n", vmid);
>> +		put_vm(vm);
>> +		return -EINVAL;
>> +	}
>> +
>> +	client_id = alloc_client();
>> +	if (unlikely(client_id < 0)) {
>> +		pr_err("acrn-ioreq: vm[%d] failed to alloc ioreq client\n",
>> +		       vmid);
>> +		put_vm(vm);
>> +		return -EINVAL;
>> +	}
>> +
>> +	client = acrn_ioreq_get_client(client_id);
>> +	if (unlikely(!client)) {
>> +		pr_err("failed to get the client.\n");
>> +		put_vm(vm);
>> +		return -EINVAL;
> 
> Do we need to clean up the alloc_client() allocation?

Thanks for the review.

The function of acrn_iocreq_get_client is used to return the client for 
the given client_id. (The ref_count of client is also added). If it is 
NULL, it indicates that it is already released in another place.

In the function of acrn_ioreq_create_client, we don't need to clean up 
the alloc_client as it always exists in course of creating_client.

> 
> regards,
> dan carpenter
> 
>> +	}
>> +
>> +	if (handler) {
>> +		client->handler = handler;
>> +		client->acrn_create_kthread = true;
>> +	}
>> +
>> +	client->ref_vm = vm;
>> +	client->vmid = vmid;
>> +	client->client_priv = client_priv;
>> +	if (name)
>> +		strncpy(client->name, name, sizeof(client->name) - 1);
>> +	rwlock_init(&client->range_lock);
>> +	INIT_LIST_HEAD(&client->range_list);
>> +	init_waitqueue_head(&client->wq);
>> +
>> +	/* When it is added to ioreq_client_list, the refcnt is increased */
>> +	spin_lock_bh(&vm->ioreq_client_lock);
>> +	list_add(&client->list, &vm->ioreq_client_list);
>> +	spin_unlock_bh(&vm->ioreq_client_lock);
>> +
>> +	pr_info("acrn-ioreq: created ioreq client %d\n", client_id);
>> +
>> +	return client_id;
>> +}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ