Received: by 10.192.165.148 with SMTP id m20csp4186174imm; Mon, 30 Apr 2018 13:26:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5MfK9CaWTE1LFVf/CNmNWekqHUrfpd8BNyLixNDWGAU3lQG9F93tHjwM1ZxWzu2x89Mac X-Received: by 2002:a17:902:8f82:: with SMTP id z2-v6mr10390782plo.350.1525120000647; Mon, 30 Apr 2018 13:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120000; cv=none; d=google.com; s=arc-20160816; b=ChYivJU4GpMG3w/MWgGXb8YXPeSHqpUlocozlCUe3bt7tzHAJ7Gm8i3dugp40x8Rd0 xlyYs6Nxsvs0Vf6GclI+Lq+NBwW7rCWwQL5a8wN0E2EGbRlKRKL4/LIMzt7qhXWkMg/+ IhtkFH418k60lbMO4if1crj2elOdNGj0+6mJcDJB6wDLz6gsP8hc9wvDk1h0htEqPy1I zVjvisAItilyf1Csb2kAV3fqNMguS7Sk8lg20HGJszzXZ9VxLlLhicHO1pDThgi4KQnN /57WdcAFHOkY4ADqm/NdDYxgft8tn+J5h+T3sG7fV9w0ysSpnBGnIL6Qr+d/sNDZ8tV3 WK+g== 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=aW+OB4dBjMIpTxss8Kxl06QcM8zirr7Cw0d/1uIUSrc=; b=gKyy7NVRCaSNa1kD/B8yNuR0lzxdQr71zH4Y09+MwHDrBEl+O6dh2KBAS/LCp8UuhY XGVLbWBFQGFj51m7SpOZbSovckhW1Tt3+E/4PkmpUx8mXaUZycqFhfl3KyCsxlG54b87 2kfjj1yesFFkBfveHxGpv0MRchd6YDtPLPfPfxsN08CqEoJXISAtb2He9OaxfeuSzXSE 9R2l8mGFQ0/P331VX54LHWdjfGgxRp+lVdjZwV939vaugh3wI422DyyRpniR1lS/QwjI 54QbX3ISgjWISh+7T5wJwyCPKFc1Tuk4sWDsTWrUJeQ4CQcUJ+CqXAxuoasBOAkDm1U/ bBbw== 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 y26-v6si357253pgv.202.2018.04.30.13.26.26; Mon, 30 Apr 2018 13:26:40 -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 S1755850AbeD3UZK (ORCPT + 99 others); Mon, 30 Apr 2018 16:25:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:60284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755672AbeD3T0b (ORCPT ); Mon, 30 Apr 2018 15:26:31 -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 E6BBA22E03; Mon, 30 Apr 2018 19:26:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6BBA22E03 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.9 32/61] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Date: Mon, 30 Apr 2018 12:24:35 -0700 Message-Id: <20180430183954.120329729@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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.9-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;