From patchwork Mon Nov 6 03:34:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10042577 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F76C603FF for ; Mon, 6 Nov 2017 03:35:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D93229116 for ; Mon, 6 Nov 2017 03:35:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31DC92949C; Mon, 6 Nov 2017 03:35:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1FA929116 for ; Mon, 6 Nov 2017 03:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751750AbdKFDfB (ORCPT ); Sun, 5 Nov 2017 22:35:01 -0500 Received: from esa3.dell-outbound.iphmx.com ([68.232.153.94]:47905 "EHLO esa3.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbdKFDeq (ORCPT ); Sun, 5 Nov 2017 22:34:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1509938878; x=1541474878; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ubiLof5iKu9iinXvweaNRjUzpMB7B3yqM6DI7JLMl4E=; b=AD85kTV7z14t7QCbyW2swppTeVGl3ry4Ut5jJZBz9SQN3eT40FPBlBob lA/1OOK1xFK0IuR+iwxmeHKhkVe7ipCuBQNkWOvjssEr8JdWazAqyNb+P RR7R1inehe1sI8nspzh9XZ+JzfvXdXTCkm6t7t8c69AePfOa8HNsGiLAL w=; Received: from esa5.dell-outbound2.iphmx.com ([68.232.153.203]) by esa3.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2017 21:27:57 -0600 Received: from ausc60ps301.us.dell.com ([143.166.148.206]) by esa5.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2017 09:32:02 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.44,350,1505797200"; d="scan'208";a="1053966446" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, Mario Limonciello Subject: [PATCH 2/2] platform/x86: dell-smbios-wmi: release mutex lock on WMI call failure Date: Sun, 5 Nov 2017 21:34:34 -0600 Message-Id: <1509939274-2813-3-git-send-email-mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509939274-2813-1-git-send-email-mario.limonciello@dell.com> References: <1509939274-2813-1-git-send-email-mario.limonciello@dell.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unbound devices may race with calling this function causing the mutex to stay locked. This failure mode should have released the mutex too. Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell-smbios-wmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c index 35c13815..5cf9b13 100644 --- a/drivers/platform/x86/dell-smbios-wmi.c +++ b/drivers/platform/x86/dell-smbios-wmi.c @@ -91,8 +91,10 @@ int dell_smbios_wmi_call(struct calling_interface_buffer *buffer) mutex_lock(&call_mutex); priv = get_first_smbios_priv(); - if (!priv) - return -ENODEV; + if (!priv) { + ret = -ENODEV; + goto out_wmi_call; + } size = sizeof(struct calling_interface_buffer); difference = priv->req_buf_size - sizeof(u64) - size; @@ -101,6 +103,7 @@ int dell_smbios_wmi_call(struct calling_interface_buffer *buffer) memcpy(&priv->buf->std, buffer, size); ret = run_smbios_call(priv->wdev); memcpy(buffer, &priv->buf->std, size); +out_wmi_call: mutex_unlock(&call_mutex); return ret;