Received: by 10.192.165.148 with SMTP id m20csp4195069imm; Mon, 30 Apr 2018 13:37:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqkNra4XdTL+29Y7kvYrWTvVVDK7J4RQ6MlY4KN5rH694B0Wh7jQE1DwF5EAF1CAwBUIOLj X-Received: by 2002:a17:902:a585:: with SMTP id az5-v6mr7573998plb.79.1525120626318; Mon, 30 Apr 2018 13:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120626; cv=none; d=google.com; s=arc-20160816; b=o15yt0IaCf1TlztSV5UnNZ4u7SLVoYk2hF69a0R/3Xmd9xx6RTBXpvjn1zHnHmDCqc J8lPNXkQYy8Z3WMr5ZTMcwClJV/nTTUjTYmaVMOtMn7VsmmoJucC/BH9ChOfcZ1JURyz k82wsEf4AA2oVpodzubTI1YmeL2h4y/1D6Pw1VgckIlbqPc3oyolcLOTkp92f1wbyU8t XFfo55RMk7/MHCobFjwtZJWDgheNNeTPduSj3IVK5vLXbZOuOBpcCRsnf4AAElEqVQD2 3XzZOi7NuuOaf+VZr3yQ5RNDzqZOE75fPHOSPGnKKRODGM4HhsQgNJ916D69GiAmNLFn mEUg== 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=zsNHgS8mJSa3H1R/fWNqC3iW/beDTQ2HzNAC13ThY6s=; b=NUFd814MkWnAIK08uDe0QNJiiXHbCpB6G2YxHxKX4I8xTpJ2HefQleqc2Q0295Vueo miC5WZZtwg9YxjLn0ltMM5YZAvOSP7q/txWIOctxFE/n82yQ2HE3HvLgH3S1NrpEfUXH Y5743vxSztjPESDyBazzuEzx4Dr6n4vz/i5K5h20UuUvJiTzIS/kljj4SlC/bQjx2xmD MYWWUmg7FHmGH3b3LpczKWTyWwDVEZidIRJxyJzzBV0bPW1yNSYRYaG491DS6d8vGsZY RYZEoSIYhXJOkbVotg+dzKlhDTLY2GRCGqeyITydNmMa56zk+h6tNvtFe56Wf2llOOZ+ w/rw== 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 p73si5242571pfk.275.2018.04.30.13.36.52; Mon, 30 Apr 2018 13:37:06 -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 S1755577AbeD3Ugh (ORCPT + 99 others); Mon, 30 Apr 2018 16:36:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:58924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755428AbeD3TZ4 (ORCPT ); Mon, 30 Apr 2018 15:25:56 -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 A6F3D22DC0; Mon, 30 Apr 2018 19:25:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6F3D22DC0 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 4.4 26/44] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Date: Mon, 30 Apr 2018 12:24:37 -0700 Message-Id: <20180430190947.384214397@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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 4.4-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;