From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D82AC606BD for ; Mon, 8 Jul 2019 15:31:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7203F21738 for ; Mon, 8 Jul 2019 15:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599876; bh=lkhV9/HANxzijUR4LfjWmtpwDhee0WU1joPW6eeOOtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bG9cHwoH+x7ZGSHSe32OES+aP3+Mrscauio+AJz2jMeM7iaSWxAMsUZSN3aEiBgIq 5moxrRepsobPBYUebGMUcK6S8+4aii73LsXYT7cPKTWIn1cFOqwpkzpucgX3ZFtyj2 oEkCOzldv7VmV/7JgpFHAU5i+E5tJNkSfXTDTm8I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389684AbfGHPbP (ORCPT ); Mon, 8 Jul 2019 11:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732189AbfGHPbN (ORCPT ); Mon, 8 Jul 2019 11:31:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 41F27216C4; Mon, 8 Jul 2019 15:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599872; bh=lkhV9/HANxzijUR4LfjWmtpwDhee0WU1joPW6eeOOtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpwbxnanDebj4Z+b2trMDrpyhbg6/ypSbnjIovlJsIvUZlSFtU+mwL1ykB3mfpIsm PH/GZdbb9ifbtZFukTJ5bdzYqj92WwET+UwwgSWI4P+34L87bQ6DN7YSuu2UViGa5Q PYJVu96K8tqDB2/H3GwCLG5EbCg9yA/jKjmKoBMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ranjani Sridharan , Takashi Iwai , Mark Brown , Sasha Levin Subject: [PATCH 5.1 18/96] ASoC: hda: fix unbalanced codec dev refcount for HDA_DEV_ASOC Date: Mon, 8 Jul 2019 17:12:50 +0200 Message-Id: <20190708150527.412917723@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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