From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D1526381A5 for ; Wed, 15 Nov 2023 20:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MWhah1pC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E5D2C4E773; Wed, 15 Nov 2023 20:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700081550; bh=0apAH5gREU/bxdpj6hujIQRSLWikV1kaJIb7pdF/5Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWhah1pCJhzDKeZtc/+QG0ltwBVOmtsoQa2ESB4pOqGQlbun2hedaWrAwcWiJZf68 h94EpAo4RS5ZNXHztsY1C2tvHkjZGRRrYXrzpjP3NAmDe/lpQs7PLOakgwxf48THYb 0aGkx9+ShGSps9npfDzCLi2DGagK8NY5C0Yw79IA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dinghao Liu , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 195/244] i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs Date: Wed, 15 Nov 2023 15:36:27 -0500 Message-ID: <20231115203600.093445694@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115203548.387164783@linuxfoundation.org> References: <20231115203548.387164783@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dinghao Liu [ Upstream commit cab63f64887616e3c4e31cfd8103320be6ebc8d3 ] put_device() needs to be called on failure of device_register() to give up the reference initialized in it to avoid refcount leak. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Signed-off-by: Dinghao Liu Link: https://lore.kernel.org/r/20230921082410.25548-1-dinghao.liu@zju.edu.cn Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/i3c/master.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index dfe18dcd008d4..b6abbb0acbbd3 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1506,9 +1506,11 @@ i3c_master_register_new_i3c_devs(struct i3c_master_controller *master) desc->dev->dev.of_node = desc->boardinfo->of_node; ret = device_register(&desc->dev->dev); - if (ret) + if (ret) { dev_err(&master->dev, "Failed to add I3C device (err = %d)\n", ret); + put_device(&desc->dev->dev); + } } } -- 2.42.0