Received: by 10.192.165.148 with SMTP id m20csp4199593imm; Mon, 30 Apr 2018 13:42:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8BbkS2i5DlS4rR7hQsOr3Yzh/xxP2FkYXM86vxdzaC98PNReOE62Pre6JZNlgGhbnki5e X-Received: by 10.98.214.5 with SMTP id r5mr13420947pfg.8.1525120973094; Mon, 30 Apr 2018 13:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120973; cv=none; d=google.com; s=arc-20160816; b=jhYBEyioBFPj8+Si5TX2TOvwSE1SiRtmrETDRowbtI97zcina7n+LXq32vkj8u4MYy LFNXcLenC8a7NfiRTxSsiZx+dS6W52P52kc6xg5cRBS1+XVH3RUgoeeZSRiK2xy7pSN0 yrfH1h+tU48V+VaqQDS05bXFhF6UgIkib3r2kFTLDgJgNzADmXOZGJ+79XaQVmRrCZmo KHs2LlrJVZmxmhR8yg6ferFCqjQvXnl9sPEQkkeiUqrqISDgVou2+G/C6/Fft/mgPAo8 +RKny1trUFSlaHSWOnD6Gh1KOAmEA3oRuFDBMXY763/1y+jOAhsstDqQtLDt50trRjrt pa0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=XiBJlB0Da7vQ2iJNpQ2OVA4JgtQLmLlbsoLupOpt4qI=; b=pNFrBCoz6Fs6R9a4T5w9mErLDFx0lWGtGqgq00ILOjyvwfB2dmcK5XX1eSvG5CmJX+ JSSM0QrbZwATdpr+VuFCOxSuEwcMUbaPIPdMa9Teph+7vskq9azbMpPa35bFGWWB4Ndw izOBhKnELmXkVYd2DuGJxyfA3KUuAHDtGj73/oiPqbWdf1YmxzNEfbRMtcCjsO6ZbKNJ +F2u+vQ4ZL5tBTJeh+7t+YeE/i0S+ZCzWJ1EoUSvJ2SH3h9Av+YLfwS2vE5wSkq0NsS1 igv4FaZB2xU62IFdG5c6SrOviQ7+DzG3TWZ997mSgzGs+zFG12FrCBwmCUjOFSGI2KmU jGig== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si6688102pgf.542.2018.04.30.13.42.38; Mon, 30 Apr 2018 13:42:53 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755498AbeD3Uma (ORCPT + 99 others); Mon, 30 Apr 2018 16:42:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:57404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbeD3TXz (ORCPT ); Mon, 30 Apr 2018 15:23:55 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50FE322DAC; Mon, 30 Apr 2018 19:23:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50FE322DAC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 3.18 17/25] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Date: Mon, 30 Apr 2018 12:23:24 -0700 Message-Id: <20180430183911.517053143@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183910.801976983@linuxfoundation.org> References: <20180430183910.801976983@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit f5e94b4c6ebdabe0f602d796e0430180927521a0 upstream. When get_synthdev() is called for a MIDI device, it returns the fixed midi_synth_dev without the use refcounting. OTOH, the caller is supposed to unreference unconditionally after the usage, so this would lead to unbalanced refcount. This patch corrects the behavior and keep up the refcount balance also for the MIDI synth device. Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/seq/oss/seq_oss_synth.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -363,10 +363,14 @@ get_synthdev(struct seq_oss_devinfo *dp, return NULL; if (! dp->synths[dev].opened) return NULL; - if (dp->synths[dev].is_midi) - return &midi_synth_dev; - if ((rec = get_sdev(dev)) == NULL) - return NULL; + if (dp->synths[dev].is_midi) { + rec = &midi_synth_dev; + snd_use_lock_use(&rec->use_lock); + } else { + rec = get_sdev(dev); + if (!rec) + return NULL; + } if (! rec->opened) { snd_use_lock_free(&rec->use_lock); return NULL;