Received: by 10.192.165.148 with SMTP id m20csp4155192imm; Mon, 30 Apr 2018 12:49:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqY4stq5k1bf99hk7uT9zbBZXGbjINgaJNbyBBBtYuO7Rc7b+n2cxznKG3eM9p1YHMZMc6F X-Received: by 2002:a63:6445:: with SMTP id y66-v6mr10948632pgb.206.1525117763860; Mon, 30 Apr 2018 12:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117763; cv=none; d=google.com; s=arc-20160816; b=klbihcrowTSAV1xB+3FetGzS4C7zpONswZmNHMKdf5IRQR7fC04hTpKL+lh+wjKpPy q1tqiq4fzpJ/o3OaFZEUoV1qx9CF8wk3JtSc+cZFbxtEoucVsnF+z1JbSniq9ty7he3X ZhjEovdu1g7oUmHDNwVtrSxHoiP7r8thHyuYPpqOuI742prd4ghbqMzikVBS2B0/FiTU WHqmF57Ucc1/aL1CdR2/f1LH1g1SqXUcj/bvbVruCN8QXD9UhKzVe7oHn8O6PFDREEwL x+OMS40ZzhS7MPrM6M/D4skWy1nwWtpJmMEHA4lSpXQuPPqifxZslIeZcHnR5zX185Kn j9hA== 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=UafsftucGLMpLcydjHq/Q0M27cvCip5NOHmE1GjZj/k=; b=NHNbsx6u3los5WfD4hG8IZqlknpyLscS52iqgG6CGf46frKc5jZKro46R+j/D/WGMW JhHdXsI2jUFV3aQQHfGltReX150sl8NNjrDBezWLvKI7dCODyPpG2WSiO8yH53lJSXNN 4gq6VMMFUrU+suXmYuG9wBPQtWO5LYILR7tyc9vxjquUnvC4GARfIyiHbM7komzcno8Y pm/djloCpXS0qYSSjrF7oo4Lyl/EFvnC+rlA6EUUhulVZc6FLzGYdRtUI9w5z2XTvPWj LIuS82uMB4Obf0dld+mwjEf7VvUHvRnJwaoF+3e+ZWJYd30x4IdhcEtA3U1UcWfUUOPp zqBA== 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 z80si6291293pfi.7.2018.04.30.12.49.09; Mon, 30 Apr 2018 12:49:23 -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 S932262AbeD3TsP (ORCPT + 99 others); Mon, 30 Apr 2018 15:48:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:35796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756244AbeD3T2R (ORCPT ); Mon, 30 Apr 2018 15:28:17 -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 8EB5A22DC1; Mon, 30 Apr 2018 19:28:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EB5A22DC1 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.16 048/113] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Date: Mon, 30 Apr 2018 12:24:19 -0700 Message-Id: <20180430184017.086433596@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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;