Received: by 10.192.165.148 with SMTP id m20csp4173158imm; Mon, 30 Apr 2018 13:10:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGUnqWqqSTY2KN9IATUP6wiZsOXcbN+LJBr8cXuJT1Wap6usolhVrjdeDyA/8PMLzHtnwe X-Received: by 10.98.133.15 with SMTP id u15mr13118065pfd.160.1525119015022; Mon, 30 Apr 2018 13:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119014; cv=none; d=google.com; s=arc-20160816; b=A4c6ZB7wG5MhHie9jpI7mvX6P8cXJ19iD+SYRESRIxUJkE6mRe5upI4nBz5tIlboCt aAEcp2yU9JL5sz4N4nXxOCJbROOK6ljDoDX3/dTeMcpL/vD30o71qLO/75lkSdGmHoHi +BZkYRaJ3I6cKp28sAXxyC6D3ZkHbHjuyUHSY2u8q1kCzCjG25XyHCZGOswU8oMD5EQp czDMxjR08CXLZhUEe0JQmHhMkeS9Q6AW+VRWCPRcPyGBQPUFTvZkmd5dzaOyhldMrUD7 I77Bp6tde2WBd0ujf6w7DiOee6MtYakVuNMxarxdp1hH7/xrLd4IQgwMB8rAesa0HhQK 9UPg== 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=/SfBPMmxVT5b3eRCVGu7QBFK4IXTqYSL7tLSt6HnbqA=; b=SapVABK2sO049NXLtu8Y77hmtZvXhW1mpq8zu88Us1mAQriemEaOgZU9KYXbO2eTDu m4S3FTnCFKC00mk4ecdJgf526IM73m8Xv0Pqek7fAlqEHc/1Mo4yPgFnDyOJ37Pk67cI LUyeJr0paih7ZVSSWeT2XYPtESSqU4pLNDTpiSAMzPGh8LjpBOZioyGf3vr8y5pL7AhK P4BwLjry1TX5xHJhZ5+J7etmVMAqQmBODZPoC2kTbBBiE1AOrauW37Egrd84M4kUCyFi 7TQGv/9HScuO/KpRm92Z8yiMmIKoz9Tkix7EaxT9ehG9TYbfQR60zCXd34AgvmYjCIzL R6Bw== 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 q9-v6si7635628plr.70.2018.04.30.13.10.00; Mon, 30 Apr 2018 13:10:14 -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 S1756053AbeD3UJs (ORCPT + 99 others); Mon, 30 Apr 2018 16:09:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:33578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755915AbeD3T1R (ORCPT ); Mon, 30 Apr 2018 15:27: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 8DBB922DC1; Mon, 30 Apr 2018 19:27:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DBB922DC1 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.14 44/91] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Date: Mon, 30 Apr 2018 12:24:26 -0700 Message-Id: <20180430184006.490057738@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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;