Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp249116ybd; Tue, 25 Jun 2019 20:43:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/yDzYOLFncj5vAhVD3H6Ep4x9Vmz8T4n9HYR2tZmWGgsJfzJGLno3EnQy7NdiEuGey7uH X-Received: by 2002:a17:902:788f:: with SMTP id q15mr2621240pll.236.1561520596982; Tue, 25 Jun 2019 20:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520596; cv=none; d=google.com; s=arc-20160816; b=gDcBrVYhuGwqQTCUxi2wmPZ6fsJlHcDtgxEjrwfYJNBRVHVFS1sZ0JbUqB0YRC7D10 EnVnqDFaxH95wyMFH1cKyXgSZj7l8Lc10/jD6jOcE/1tUGc8V9OjhhmbgFamYa1s9wYn nh0kDw7k1Vn7wXhsOeH8O7CYk7E4wpujf9tryd+081SCGHdLPILSt+RcxuxdjxI2xj3B elsRPnDVDHqX/rVTzbM0aJt6T2WEg+EDh4AVrLocAX8D/PLfIGtfYd8NWZdyrvHk96VJ Wp+xZN9u9O6+XvJgFPlaN5ruQYvZHGbSyUo5ykrsIxt4lRprez7O/B97i3dRvVDWxQnx rj9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+QpWA3zkgpdwdft2KUVBExK2Vvf9SRpg9s8Il2vMVI4=; b=a0Du698TvFJ4EHifM8EhiLj3qPEVwz61JsuwIU3ZpMDRaV0NrJxeJgQRpeyGo0HJZN Gp/ygg+elemrIG0jAnxfAgx6RbzIpT7xsU4suCjoUJH+TPI54JMciuLOkTx3kZobwIO9 3MtH1Pa3T6WNsNqgcERo9rLA+mXljE1yV/APASZ5WQyZwsI5UU87K78GailUPDPp2VuI g5ZTZsE2+qpZw+ia7Uu727QM/AQyKeEbnAoggvTA+qJ+nreJlW9XTDEovxdwXt5ZKHTG /04s9N7TzTr/0HB8uf9o9jGcdnjKeFNtnAAfkgf2go2XUCKiciLTb/qIx1Qx2D9zGe27 h/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=syAouCE8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si14767807pgw.395.2019.06.25.20.43.01; Tue, 25 Jun 2019 20:43:16 -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; dkim=pass header.i=@kernel.org header.s=default header.b=syAouCE8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfFZDlx (ORCPT + 99 others); Tue, 25 Jun 2019 23:41:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:52432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbfFZDlv (ORCPT ); Tue, 25 Jun 2019 23:41:51 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A6472146E; Wed, 26 Jun 2019 03:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520510; bh=qZrYUCu2arjVH/XGWiobP8O3+hLn3+p6Pl5mkDCDoGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syAouCE8AJeMVLdI2m4k9MGtpxcGRLrAJ4Ar11juy5RelW8GcAI/jy+0JOxq1vqSF bVY1CYYkpEE5q51zbpqJypNhrowvl7szUrcWlQSva1fj0Ogq4qKK1tHJz0ldaWVB2n W0UQtIaiTnY6mnlqBE+qu5deR/S3shaT8LTnZIbI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ranjani Sridharan , Takashi Iwai , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.1 14/51] ASoC: hda: fix unbalanced codec dev refcount for HDA_DEV_ASOC Date: Tue, 25 Jun 2019 23:40:30 -0400 Message-Id: <20190626034117.23247-14-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ranjani Sridharan [ Upstream commit d6947bb234dcc86e878d502516d0fb9d635aa2ae ] HDA_DEV_ASOC type codec device refcounts are managed differently from HDA_DEV_LEGACY devices. The refcount is released explicitly in snd_hdac_ext_bus_device_remove() for ASOC type devices. So, remove the put_device() call in snd_hda_codec_dev_free() for such devices to make the refcount balanced. This will prevent the NULL pointer exception when the codec driver is released after the card is freed. Signed-off-by: Ranjani Sridharan Reviewed-by: Takashi Iwai Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/pci/hda/hda_codec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index b20eb7fc83eb..fcdf2cd3783b 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -840,7 +840,14 @@ static int snd_hda_codec_dev_free(struct snd_device *device) if (codec->core.type == HDA_DEV_LEGACY) snd_hdac_device_unregister(&codec->core); codec_display_power(codec, false); - put_device(hda_codec_dev(codec)); + + /* + * In the case of ASoC HD-audio bus, the device refcount is released in + * snd_hdac_ext_bus_device_remove() explicitly. + */ + if (codec->core.type == HDA_DEV_LEGACY) + put_device(hda_codec_dev(codec)); + return 0; } -- 2.20.1