mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
dm: mei: destroy mutex attribute on error path
Simplify the flow by adding mutex_type variable and call pthread_mutexattr_destroy() on the error path. Tracked-On: #1630 Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
This commit is contained in:
parent
8abc931791
commit
b4fbef4659
@ -2123,6 +2123,7 @@ vmei_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
struct virtio_mei *vmei;
|
struct virtio_mei *vmei;
|
||||||
char tname[MAXCOMLEN + 1];
|
char tname[MAXCOMLEN + 1];
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
|
int mutex_type;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
char *opt;
|
char *opt;
|
||||||
@ -2197,21 +2198,17 @@ init:
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtio_uses_msix()) {
|
mutex_type = virtio_uses_msix() ?
|
||||||
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
|
PTHREAD_MUTEX_DEFAULT :
|
||||||
if (rc) {
|
PTHREAD_MUTEX_RECURSIVE;
|
||||||
WPRINTF("init: mutexattr_settype failed, error %d!\n",
|
|
||||||
rc);
|
rc = pthread_mutexattr_settype(&attr, mutex_type);
|
||||||
goto fail;
|
if (rc) {
|
||||||
}
|
pthread_mutexattr_destroy(&attr);
|
||||||
} else {
|
WPRINTF("init: mutexattr_settype failed, error %d!\n", rc);
|
||||||
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
goto fail;
|
||||||
if (rc) {
|
|
||||||
WPRINTF("init: mutexattr_settype failed, error %d!\n",
|
|
||||||
rc);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = pthread_mutex_init(&vmei->mutex, &attr);
|
rc = pthread_mutex_init(&vmei->mutex, &attr);
|
||||||
pthread_mutexattr_destroy(&attr);
|
pthread_mutexattr_destroy(&attr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user