[PATCH] Unlock the storage pool objects after looking it up

李义 yilikernel at gmail.com
Thu May 7 11:27:56 UTC 2020


On 5/7/20, Peter Krempa <pkrempa at redhat.com> wrote:
> On Thu, May 07, 2020 at 18:48:55 +0800, Yi Li wrote:
>> The lock should be released.
>>
>> Signed-off-by: Yi Li <yili at winhong.com>
>> ---
>>  src/conf/virstorageobj.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
>> index 13b75b648d..9f24ae67ca 100644
>> --- a/src/conf/virstorageobj.c
>> +++ b/src/conf/virstorageobj.c
>> @@ -2077,8 +2077,10 @@ virStoragePoolObjListExport(virConnectPtr conn,
>>
>>      virObjectRWLockRead(poolobjs);
>>
>> -    if (pools && VIR_ALLOC_N(data.pools, virHashSize(poolobjs->objs) + 1)
>> < 0)
>> -        goto error;
>> +    if (pools && VIR_ALLOC_N(data.pools, virHashSize(poolobjs->objs) + 1)
>> < 0) {
>> +        virObjectRWUnlock(poolobjs);
>> +        return -1;
>> +    }
>
> In this instance, I'd prefer if VIR_ALLOC_N is replaced by g_new0 which
> will not fail and thus the unlock will not be necessary as there will be
> no cleanup path.
>
>
Thanks, i will redo it.





More information about the libvir-list mailing list