From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-201.mta1.migadu.com [95.215.58.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F13AE446C18 for ; Fri, 4 Sep 2026 09:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514554; cv=none; b=MlnBR5v3UMvU4dU+Jcv1B3oWBqBkP7MXqiiOnRVkJL655WdHn3LN9btZUaack13qSA6k00Z8SKAc9NSQ4ZpnTvmKFgZubFURrrLdCYrjbKr0WYjtAwWSS0m4WeArRZkLjp1dT2n8ZdFOH6ZwZqq6ZEsfvcGi0dQfA3l1rYTFy4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514554; c=relaxed/simple; bh=LfO1/eqlAVD+ofSYiszO71g9ocWquBTr4eOFRXWuc8k=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=f5WkwtmO0hmzRqWH8kU96JX5SgA8RBtD7/KG+b544yPXnA7ofz32S1uguzFoam7tBcwYG0DXNWVSQryOMHIQ+75aleR1IOSi6FruGwwtXucvHrKCa5HHJiW0oxxoH7c7/r2VpXsojYFp02G/Y7hcoqO3Vy9L1N5iMhnmYlXJ62I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=itRzco7R; arc=none smtp.client-ip=95.215.58.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="itRzco7R" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=LfO1/eqlAVD+ofSYiszO71g9ocWquBTr4eOFRXWuc8k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1788514551; v=1; x=1789119351; b=itRzco7RSv9Xt2qT3tmxTPrdd3vf0Blz8VWe7xJOGpENuh6AXYH+8AtOQxg25nRVw6mclh4+ 1lF2cSZ9hGxSoz1kCNvnWlDA5tTzFr7GcyhVT9ERrWxi8ewbcKoH72755uP+W2Gc2ajbkgPFeeK IE4kcwLZ3l8GToAiWRX03zfY= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 1529718b5a2987b1; Fri, 04 Sep 2026 09:35:50 +0000 X-Mizu-Trace-ID: 1529718b5a2987b1 X-Migadu-Flow: FLOW_OUT Message-ID: <08b5843b-33f0-4c33-8db6-c23da0c9b685@linux.dev> Date: Fri, 4 Sep 2026 17:35:44 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: shawn.lin@linux.dev, Hans de Goede , Sascha Hauer , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mmc: core: Fix OF node reference leak on card add failure To: Zhu Ling , Ulf Hansson References: From: Shawn Lin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2026/09/04 ζ˜ŸζœŸδΊ” 17:07, Zhu Ling wrote: > mmc_of_find_child_device() returns a device node with its reference count > incremented. mmc_add_card() stores the reference before calling > device_add(), while the card is marked present only after device_add() > succeeds. > > If device_add() fails, the callers release the card through > mmc_remove_card(). However, mmc_remove_card() only drops the OF node > reference for a present card, leaking the reference on this error path. > > Move of_node_put() outside the present-card conditional so the reference > is released for both registered cards and card-add failures. > > Fixes: 25185f3f31c9 ("mmc: Add SDIO function devicetree subnode parsing") > Cc: stable@vger.kernel.org > Signed-off-by: Zhu Ling > --- Reviewed-by: Shawn Lin > drivers/mmc/core/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c > index be5cf338bdeb..92ad39c0cabc 100644 > --- a/drivers/mmc/core/bus.c > +++ b/drivers/mmc/core/bus.c > @@ -417,8 +417,8 @@ void mmc_remove_card(struct mmc_card *card) > mmc_hostname(card->host), card->rca); > } > device_del(&card->dev); > - of_node_put(card->dev.of_node); > } > + of_node_put(card->dev.of_node); > > if (host->cqe_enabled) { > host->cqe_ops->cqe_disable(host); > >