From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F15EA3DC4D5 for ; Mon, 4 May 2026 13:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903143; cv=none; b=fhymptX5tZgJ0NwI/7qdTdSSRikPtcLkngvfv8d1+wcpZNHUbr//4y2OVToy6LbPXIQnGwruxcsEqAPq4F//AITPEXex/5CntTf63qRJQg3cBb327n8J4IyWALKCLU3iZcLunbXIVpDG1fSdWv68+wKXRJ1/KHBfkVETOKZafvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903143; c=relaxed/simple; bh=gOGLBCbpHD5jUNJprldmV5V8WZ1GfuJwuregfRGrSjE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=tTfQrKChTM78YYW5FKwx/y7eg1yIJ22vl3VNJjB0hHM7W+1sDhN/XkJDnU/Qm2Bv7qJJDZaQQRjFqvAdId1SeSX5m9SRpSoZASDu737Hu/2CfxsN39LSKryNjNc9s5JEhTWbkUmkKhImkAMu69iqWXENXXzv+WrEyRM8YFKuR5o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KOoBPuZ8; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KOoBPuZ8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id CB93AC5D72D; Mon, 4 May 2026 13:59:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 69A915FD5F; Mon, 4 May 2026 13:58:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B737E11AD2449; Mon, 4 May 2026 15:58:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777903138; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=LVrH+hRa8k60712RPQs7XAU8jqIwLgDkBraOs0In2Cc=; b=KOoBPuZ8iPsqVJviZXRPur58W4+JFX2f+4e1Yw2f62tBEjd3M/aDEw1paPJy7ALa2H3qiA DGBZfFGDu+PCKMTqLGRCgqsBPtOg1zI1apECUFvNwyW230zpPrzczAmwnBusuwnnuy013J DEqVNFYwkAK1wsTRcLzbxR8X1ApVq6zAPansft6cn28IfpDvJAssHkX1K4JAI8Q1rJyH43 /dQjB7cGMcrekjEwPSLABk+OXXQrbsvrkLjNMzgcHmqj5o+bwQZl9MFV8+Lyy/P48PmpzD eQFYHcXKEOasY8/e7LJtXeMmbBDmJxda19p/PwuSTJtn6SjuYp6cKX9CtVUGxg== From: Miquel Raynal To: Vastargazing Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Richard Weinberger , Vignesh Raghavendra , David Woodhouse , Lennert Buytenhek , linux-mtd@lists.infradead.org Subject: Re: [PATCH 3/5] mtd: maps: physmap: fix reference leak on failed device registration In-Reply-To: <6717e0b2a6244ee4e691dba03eb8c790c202e89e.1777889235.git.vebohr@gmail.com> (Vastargazing's message of "Mon, 4 May 2026 13:08:45 +0300") References: <6717e0b2a6244ee4e691dba03eb8c790c202e89e.1777889235.git.vebohr@gmail.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Mon, 04 May 2026 15:58:56 +0200 Message-ID: <87a4ufs2cf.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 On 04/05/2026 at 13:08:45 +03, Vastargazing wrote: > When platform_device_register() fails in physmap_init(), the embedded > struct device has already been initialized by device_initialize() inside > platform_device_register(). The error path unregisters the driver but > returns without dropping the device reference: > > physmap_init() > -> platform_device_register(&physmap_flash) > -> device_initialize(&physmap_flash.dev) /* kref =3D 1 */ > -> platform_device_add(&physmap_flash) /* fails */ > <- platform_driver_unregister() called, but kref still 1 > > Per platform_device_register() kernel-doc: > > NOTE: _Never_ directly free @pdev after calling this function, even if > it returned an error! Always use platform_device_put() to give up the > reference initialised in this function instead. > > Fix this by calling platform_device_put() before unregistering the driver. > > Fixes: 73566edf9b91 ("[MTD] Convert physmap to platform driver") > Cc: stable@vger.kernel.org > Assisted-by: GitHub Copilot (Claude Sonnet 4.5) > Signed-off-by: Vastargazing Somehow b4 applied another patch from that series, I'm not sure why. I just dropped it. Please resend this patch alone. Also, your SoB line seems to be incorrect, we need a proper name, please have a loot at the DCO. Thanks, Miqu=C3=A8l