From patchwork Tue Nov 5 20:07:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 178554 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1238145ilf; Tue, 5 Nov 2019 12:08:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzTkU9X8lhT+mtLXbQmFzicHqKAMPxHTkkRFXk1H1PHAngF6jU7ZFcLbkzyeIn4UkhPcTHW X-Received: by 2002:a17:906:698b:: with SMTP id i11mr2692464ejr.97.1572984496775; Tue, 05 Nov 2019 12:08:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1572984496; cv=pass; d=google.com; s=arc-20160816; b=g5pD5auosoqtiEHN/SMow/zL2D8C1lCvsForxs3uxMivx4B7WFWqXHMlOPTiBP5bx7 kG4yrC3CeawRrmSK8VhVwn4HZVM9wVBh70J99IKFdppANoJtFE9YtpTKfvSim/ex3R2Z S3cIPIm4BmkxSzyPNHAgiSKOZ6wRv9e+lW5tTwacHpdCaTGipBB4S0mtIXjRp+KOkJb0 QhVDxYbfBLtq5H52BUHONYoWeL4hWRukCTKd7utTp6fhjAC4ZBZYJdJkLO8VOzJ7n1Gl YrMckd2hqemISHhcN0V0I2EpzKNpAGVknKNZa4p/8+9TQRGJ1w16cgxmJl89NBnEofGx SPcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-signature; bh=ZHMpbuCZSxHqKhlmBWIMNytQ4fYuc+eIfTKZioaof2c=; b=jF4HqgdD4jzXGXW/CRflio/N5JADI/0rAaCEI2etc6B5lTgPYRQsiGIh8F364Z6bfT vBmEm9yWxiG3pSMYt/bdCJtaLoZx6bxgBrAVCJEujkkXMgeBwT2JEbJKAm3WaiRErHUp ghXSulU5vd339avGvPBJtuTbvoBg63/qHKs9jEnjlh4RSeJE64IGj5pjYj5a7dnQeBtI PEwuS3fj+ioXTOCZWer7GY6Feg8MEE56Uhv9pCIMQbsQ3a4S7s2Yks206n4CtcjkdcyK TJFBX6KzBCfqufkqBHZQ8rOFTCNyNzCBntE0kHWmwNX9u9WEvf1yUvSInEFfgJGheZqP x7MQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=nTUJxvMJ; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=PVJ6t4GJ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si10884334edj.220.2019.11.05.12.08.16; Tue, 05 Nov 2019 12:08:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=nTUJxvMJ; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=PVJ6t4GJ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729607AbfKEUIM (ORCPT + 26 others); Tue, 5 Nov 2019 15:08:12 -0500 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:35162 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725806AbfKEUIM (ORCPT ); Tue, 5 Nov 2019 15:08:12 -0500 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xA5K6QQA009871; Tue, 5 Nov 2019 12:07:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=ZHMpbuCZSxHqKhlmBWIMNytQ4fYuc+eIfTKZioaof2c=; b=nTUJxvMJdduV5zzkzY0hvKA9x6VDUrstYEIJ6qQ51lBDHMLv0b0RiH3Km/qXkG8xV4kT Qzplgi4VOEw42f2LqlfS9/uMgeb6Wyu3x1++1Q6OybTbz8OOi5O51b1QC9Rm8IAFgVYf THHR6tiOPXVTR+wIHWDfvrZnZIDM8bAFNoKcRdE2Kv6O5uJbzbqRpas6Vu9Me9B6weEg H3/lGk3xcLHgFei5MKGI6+XyYjFxhLpieBuvS7kOqhFDVJjE0yDdgzDfZhbb9Oarb9c/ G9S9Uy70BD1ZI9AaqBst4JhzoezCjIWp4aD/Qnaj73SrQ8vIXuPGpXwZgjrZkQegBNcR wQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2w3eud08wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 05 Nov 2019 12:07:54 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 5 Nov 2019 12:07:53 -0800 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (104.47.40.58) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 5 Nov 2019 12:07:53 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=crGmPKjt8FPln00dfmNNgz5SXK+esMIZ+ErkXYKC974U0UuzYk07GYGyaC8uO2L55SWHM14VPasqLd9WRZY/S3lnPLZ1n0VIsq1QKTlb4klYvs9W+g8vKLbSyma+Q6AWAXUZbMlgIQwkFDWL9u0+3f+i5M/1K5FSaqJygWax57+UNKH5fbcXdbhLQcYVg4p4gDV1lidkTZeTZiBcWfE4UP1mhVFbBjhwhhrEa3qHfLmhbgZ9DKG0kBe0IYtEF1UGi8Igyw152W9/JyhDJRFwuSAa7VUQrXdUe0/ZzwYNgREqeTSA+v39V9weQxOVCmH3NL3I0JohHuDe+xINCMoo9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZHMpbuCZSxHqKhlmBWIMNytQ4fYuc+eIfTKZioaof2c=; b=a9Z8oiBIo7Cl+gpxH7kXOr99FvKwuIx5TjE2psLYZ2FYgT9qQCgottDfAr36tbLPSUuXYmE5B/dyDguokDLO3VwSRdgRngJbo26p20OOPu3EA/OurbPN48p0a5oWYuwwYekKB1YAy0LHdRTFLI9s/h8RATs1Pjxoa4AbiWgCxhcOScQREpgHVZ2nwaQjjj1mxdSLKlN+F7gOem1tsPAQJeqArBEx3z3nLbnf33ptvvBqWp6x0MpfrGgsnf9hbxtJhM23lUvLu/N0I/+B5R9SWjix+byh8rQioT0eHSnkflud/1cns7T8sVaGFIdejJxRpm0tzT3S51fgeUimT0z4lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZHMpbuCZSxHqKhlmBWIMNytQ4fYuc+eIfTKZioaof2c=; b=PVJ6t4GJOz6v4VcTPr6ea9wygAp6wxkrIoexqE0iL45lgUI/0cQVX+rTRGPNC3mbiaZk566qQtvNLpM5ALtBkyxJx+MCyD/HlM5B32ol3ATr4NFbAOVqpaC9QDIeHbxTjt00nifq1bGkn02rt84/mkLYjefVTfd+bvLH7c8PWaw= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.237.10) by MN2PR18MB3085.namprd18.prod.outlook.com (20.179.21.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Tue, 5 Nov 2019 20:07:51 +0000 Received: from MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::c4a:cf3c:f530:fba6]) by MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::c4a:cf3c:f530:fba6%6]) with mapi id 15.20.2408.024; Tue, 5 Nov 2019 20:07:51 +0000 From: Robert Richter To: James Morse , Mauro Carvalho Chehab , Borislav Petkov , Tony Luck CC: Robert Richter , Borislav Petkov , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v3] EDAC, ghes: Fix locking and memory barrier issues Thread-Topic: [PATCH v3] EDAC, ghes: Fix locking and memory barrier issues Thread-Index: AQHVlBSz45Hg5fqU9kW80JLQAsOb9w== Date: Tue, 5 Nov 2019 20:07:51 +0000 Message-ID: <20191105200732.3053-1-rrichter@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0802CA0004.eurprd08.prod.outlook.com (2603:10a6:3:bd::14) To MN2PR18MB3408.namprd18.prod.outlook.com (2603:10b6:208:165::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [31.208.96.227] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ffa3488e-7387-48a6-cc11-08d7622bd5e6 x-ms-traffictypediagnostic: MN2PR18MB3085: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1284; x-forefront-prvs: 0212BDE3BE x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(39860400002)(396003)(376002)(346002)(136003)(199004)(189003)(1076003)(66476007)(14454004)(316002)(8676002)(86362001)(5660300002)(110136005)(50226002)(66556008)(4326008)(25786009)(99286004)(2906002)(478600001)(386003)(64756008)(66446008)(52116002)(36756003)(8936002)(81156014)(6506007)(81166006)(26005)(71200400001)(14444005)(71190400001)(2616005)(3846002)(6116002)(6512007)(66946007)(54906003)(102836004)(6486002)(476003)(486006)(6436002)(7736002)(66066001)(186003)(256004)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3085; H:MN2PR18MB3408.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TnHr6GqvnsZtX48vbFeuZ0brFXj7mL/kymucsBGB2sPfRGW8HAhxyLIZk3iTTLYMglVJd1+b/4Lx2H9u/lbCO5DUFXXzOSrrAO8mZqk2cPnDUh8cBjHZm2VdZFOgP6HMt0UtNvYCaqhujkFqkTke7/+iYWmGmjWl8U61pUrDCluQfLX007rrgvxh7JaCWKH9lnHF4qTl8XVIlqUdu0sucT0VCA72aHo5W0DJGLSVZkRtULsNXqeAmkh3kESDHuDSZ8QzRwgeR0smWfMx3iS00wXb/6lsE+h8GQL5wXN4grQnVm/6ZVJe15x7XIotiNYIyRaGNfH4U7yaqJIqsNAyoU0xmvkP1mFibUYIoXNfkJUnblGhBQE2irCGbuyTuorBgTLl4gRvLk9nGPhVDKMrLXnXa9Sb5SuBC8nfE4vEp2mEiJKwv2AjMvt977TKdLsb MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: ffa3488e-7387-48a6-cc11-08d7622bd5e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2019 20:07:51.1131 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Uc/qqBgDTIhye5QGRLGw/o0gBwlF8BmfMVNrIefVSbmnPsqt9m3CIKAyXEixIAGmS3mLEUijxd8v0RH0q7EftA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3085 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-11-05_07:2019-11-05,2019-11-05 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ghes registration and refcount is broken in several ways: * ghes_edac_register() returns with success for a 2nd instance even if a first instance is still running. This is not correct as the first instance may fail later. A subsequent registration may not finish before the first. Parallel registrations must be avoided. * The refcount was increased even if a registration failed. This leads to stale counters preventing the device from being released. * The ghes refcount may not be decremented properly on unregistration. Always decrement the refcount once ghes_edac_unregister() is called to keep the refcount sane. * The ghes_pvt pointer is handed to the irq handler before registration finished. * The mci structure could be freed while the irq handler is running. Fix this by adding a mutex to ghes_edac_register(). This mutex serializes instances to register and unregister. The refcount is only increased if the registration succeeded. This makes sure the refcount is in a consistent state after registering or unregistering a device. Note: A spinlock cannot be used here as the code section may sleep. The ghes_pvt is protected by ghes_lock now. This ensures the pointer is not updated before registration was finished or while the irq handler is running. It is unset before unregistering the device including necessary (implicit) memory barriers making the changes visible to other cpus. Thus, the device can not be used anymore by an interrupt. Also, rename ghes_init to ghes_refcount for better readability and switch to refcount API. A refcount is needed. There can be multiple GHES structures being defined (see ACPI 6.3 specification, 18.3.2.7 Generic Hardware Error Source, "Some platforms may describe multiple Generic Hardware Error Source structures with different notification types, ..."). Another approach to use the mci's device refcount (get_device()) and have a release function does not work here. A release function will be called only for device_release() with the last put_device() call. The device must be deleted *before* that with device_del(). This is only possible by maintaining an own refcount. Fixes: 0fe5f281f749 ("EDAC, ghes: Model a single, logical memory controller") Fixes: 1e72e673b9d1 ("EDAC/ghes: Fix Use after free in ghes_edac remove path") Co-developed-by: James Morse Signed-off-by: James Morse Co-developed-by: Borislav Petkov Signed-off-by: Borislav Petkov Signed-off-by: Robert Richter --- V3: * fixed SOB chain again (added SOBs according to submitting-patches.rst) V2: * fixed missing 'goto unlock' in error path * fixed SOB chain * added comment on how to protect ghes_pvt with ghes_lock * renamed ghes_init to ghes_refcount * switched to refcount API instead of atomic_* --- drivers/edac/ghes_edac.c | 89 +++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 24 deletions(-) -- 2.20.1 diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 0bb62857ffb2..5da85ef7966d 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -26,9 +26,18 @@ struct ghes_edac_pvt { char msg[80]; }; -static atomic_t ghes_init = ATOMIC_INIT(0); +static refcount_t ghes_refcount = REFCOUNT_INIT(0); + +/* + * Access to ghes_pvt must be protected by ghes_lock. The spinlock + * also provides the necessary (implicit) memory barrier for the SMP + * case to make the pointer visible on another cpu. + */ static struct ghes_edac_pvt *ghes_pvt; +/* GHES registration mutex */ +static DEFINE_MUTEX(ghes_reg_mutex); + /* * Sync with other, potentially concurrent callers of * ghes_edac_report_mem_error(). We don't know what the @@ -79,9 +88,8 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } -static int get_dimm_smbios_index(u16 handle) +static int get_dimm_smbios_index(struct mem_ctl_info *mci, u16 handle) { - struct mem_ctl_info *mci = ghes_pvt->mci; int i; for (i = 0; i < mci->tot_dimms; i++) { @@ -198,14 +206,11 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) enum hw_event_mc_err_type type; struct edac_raw_error_desc *e; struct mem_ctl_info *mci; - struct ghes_edac_pvt *pvt = ghes_pvt; + struct ghes_edac_pvt *pvt; unsigned long flags; char *p; u8 grain_bits; - if (!pvt) - return; - /* * We can do the locking below because GHES defers error processing * from NMI to IRQ context. Whenever that changes, we'd at least @@ -216,6 +221,10 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) spin_lock_irqsave(&ghes_lock, flags); + pvt = ghes_pvt; + if (!pvt) + goto unlock; + mci = pvt->mci; e = &mci->error_desc; @@ -348,7 +357,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p += sprintf(p, "DIMM DMI handle: 0x%.4x ", mem_err->mem_dev_handle); - index = get_dimm_smbios_index(mem_err->mem_dev_handle); + index = get_dimm_smbios_index(mci, mem_err->mem_dev_handle); if (index >= 0) { e->top_layer = index; e->enable_per_layer_report = true; @@ -443,6 +452,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) grain_bits, e->syndrome, pvt->detail_location); edac_raw_mc_handle_error(type, mci, e); +unlock: spin_unlock_irqrestore(&ghes_lock, flags); } @@ -457,10 +467,12 @@ static struct acpi_platform_list plat_list[] = { int ghes_edac_register(struct ghes *ghes, struct device *dev) { bool fake = false; - int rc, num_dimm = 0; + int rc = 0, num_dimm = 0; struct mem_ctl_info *mci; + struct ghes_edac_pvt *pvt; struct edac_mc_layer layers[1]; struct ghes_edac_dimm_fill dimm_fill; + unsigned long flags; int idx = -1; if (IS_ENABLED(CONFIG_X86)) { @@ -472,11 +484,14 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) idx = 0; } + /* finish another registration/unregistration instance first */ + mutex_lock(&ghes_reg_mutex); + /* * We have only one logical memory controller to which all DIMMs belong. */ - if (atomic_inc_return(&ghes_init) > 1) - return 0; + if (refcount_inc_not_zero(&ghes_refcount)) + goto unlock; /* Get the number of DIMMs */ dmi_walk(ghes_edac_count_dimms, &num_dimm); @@ -494,12 +509,13 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(struct ghes_edac_pvt)); if (!mci) { pr_info("Can't allocate memory for EDAC data\n"); - return -ENOMEM; + rc = -ENOMEM; + goto unlock; } - ghes_pvt = mci->pvt_info; - ghes_pvt->ghes = ghes; - ghes_pvt->mci = mci; + pvt = mci->pvt_info; + pvt->ghes = ghes; + pvt->mci = mci; mci->pdev = dev; mci->mtype_cap = MEM_FLAG_EMPTY; @@ -541,23 +557,48 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) if (rc < 0) { pr_info("Can't register at EDAC core\n"); edac_mc_free(mci); - return -ENODEV; + rc = -ENODEV; + goto unlock; } - return 0; + + spin_lock_irqsave(&ghes_lock, flags); + ghes_pvt = pvt; + spin_unlock_irqrestore(&ghes_lock, flags); + + /* only increment on success */ + refcount_inc(&ghes_refcount); + +unlock: + mutex_unlock(&ghes_reg_mutex); + + return rc; } void ghes_edac_unregister(struct ghes *ghes) { struct mem_ctl_info *mci; + unsigned long flags; - if (!ghes_pvt) - return; + mutex_lock(&ghes_reg_mutex); - if (atomic_dec_return(&ghes_init)) - return; + if (!refcount_dec_and_test(&ghes_refcount)) + goto unlock; - mci = ghes_pvt->mci; + /* + * Wait for the irq handler being finished. + */ + spin_lock_irqsave(&ghes_lock, flags); + mci = ghes_pvt ? ghes_pvt->mci : NULL; ghes_pvt = NULL; - edac_mc_del_mc(mci->pdev); - edac_mc_free(mci); + spin_unlock_irqrestore(&ghes_lock, flags); + + if (!mci) + goto unlock; + + mci = edac_mc_del_mc(mci->pdev); + if (mci) + edac_mc_free(mci); + +unlock: + mutex_unlock(&ghes_reg_mutex); }