Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2813768pxb; Mon, 18 Apr 2022 08:46:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztdQm40FcfAh+1HCLIQ8dzriIPA7T3LRTRdQPRvwoNZyqPO+h0YNd222eyT6lrLm2FSYuZ X-Received: by 2002:a17:907:60d3:b0:6e7:fcd6:7fb4 with SMTP id hv19-20020a17090760d300b006e7fcd67fb4mr9931178ejc.302.1650296781590; Mon, 18 Apr 2022 08:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650296781; cv=none; d=google.com; s=arc-20160816; b=Us+vWfYdzUVK34g7u9bSwTcM3PbvDIRY6w7EW7+zWe00Vl57WpA9gZ7Ha+CH1f+1DS O2aHFlEtKm7/8MTwjKB4ZY0EuwycHQMa3C8+EjAklmWkZE/pPlRx3qfFKjnFf6QiMtA+ MsJNDkL1mIqVS45R0t/CA8cRVQSZ6sLTnrOLu9z9lBJJBJy3oKNHy7dAbtaU9OzQfqwh yvlba7kEDOnzHpzMIvHx23cmI+qKpqIfniQDDJ6M40USXorjtoojh6x4tccimAgeBJbW dM8Uohe2V3qozRGiDG7yKg/yEZqFZWGOypcf1WvmHHVM03SfOaE7BdGr9mX/UkBiq4tA tuBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jbs3DAmY+gFdfvL+2hoBpjItLlR0WKbO63V+W/OQCOM=; b=UxxEqbWtfRVn5A0CR+8/BPPvb2bOz17j6/8OjiYmFK5A60/jaR3Y+n1nKeDn+euPNt jXr1bSG2YBQ1uP+90BinheKWmQ9kBi+cd8LKfWludvSvpZNuUDoQm23xXHtuAfNLoH3T 0mSPq8vV7a6jechb4nGcXZ9b0NF5K4kCuwlUL3kllrxaSo9KT8lVerZICjUuBIEvbXRo z/EZ5oWOwcARBYqeiAUnM4AKEPyQ4zJepOEl7RWQ9BdZ/URFKeLu/Gi2rFz/jrYrEqLR ZnKHBiR4u1JsQucXUEJEot8X+BE5mqi7p/7oorNeKsUOl65vIYsWg7s7y9VcwijtRJj7 0rRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h61tvhmE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020a170906695900b006df76385d13si6397164ejs.435.2022.04.18.08.45.57; Mon, 18 Apr 2022 08:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h61tvhmE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236257AbiDRMbh (ORCPT + 99 others); Mon, 18 Apr 2022 08:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239269AbiDRM2O (ORCPT ); Mon, 18 Apr 2022 08:28:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9803E1EC58; Mon, 18 Apr 2022 05:21:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 03E3CB80EDB; Mon, 18 Apr 2022 12:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 520F4C385A8; Mon, 18 Apr 2022 12:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284490; bh=szVwhci6wEG2scB742G2j4/7NAzzTzIVcKJbFqCQBr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h61tvhmEZksFoau9u/J4xbBLQ+jWJodtYjvOnRDIuKz6DX/rSFvIGggAKkwQFdr6N Rkop0yCPDYUqyPhik8UkYwzHcEGHtCf/OfQgnw8uYV9IyfWvfnBInJCpfCkBXVmknL bcFC2c27JYRuQ3Ub41wBEVDNeybk8oshrkanj84c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 5.17 108/219] ALSA: ad1889: Fix the missing snd_card_free() call at probe error Date: Mon, 18 Apr 2022 14:11:17 +0200 Message-Id: <20220418121209.921906971@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit a8e84a5da18e6d786540aa4ceb6f969d5f1a441d ] The previous cleanup with devres may lead to the incorrect release orders at the probe error handling due to the devres's nature. Until we register the card, snd_card_free() has to be called at first for releasing the stuff properly when the driver tries to manage and release the stuff via card->private_free(). This patch fixes it by calling snd_card_free() on the error from the probe callback using a new helper function. Fixes: 567f58754109 ("ALSA: ad1889: Allocate resources with device-managed APIs") Link: https://lore.kernel.org/r/20220412102636.16000-4-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/ad1889.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index bba4dae8dcc7..50e30704bf6f 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -844,8 +844,8 @@ snd_ad1889_create(struct snd_card *card, struct pci_dev *pci) } static int -snd_ad1889_probe(struct pci_dev *pci, - const struct pci_device_id *pci_id) +__snd_ad1889_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) { int err; static int devno; @@ -904,6 +904,12 @@ snd_ad1889_probe(struct pci_dev *pci, return 0; } +static int snd_ad1889_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) +{ + return snd_card_free_on_error(&pci->dev, __snd_ad1889_probe(pci, pci_id)); +} + static const struct pci_device_id snd_ad1889_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) }, { 0, }, -- 2.35.1