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 6A318364BE for ; Wed, 15 Nov 2023 19:34:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uCySZsIg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ABB7C433C9; Wed, 15 Nov 2023 19:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700076871; bh=MXQAuCpBRpD7QpaXiLUnxCtVjcZDJPfCseEOQIeMX1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uCySZsIgVoBwr/7kg6EEwX5FZOeXxJksGPY+WkLujlnvrXmL8d0YFNRlTz5tyzAOF KFo2c+DXY0LeOBnMUEMfhrDHFLGCBhDO0y7dSrwYWXWQx5bsCqi0dShW/DKZ5waTZA xTjCpz08y1gm1ylEkTBHs0MuWQS8PaVJjmVyq2KQ= 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 6.5 449/550] i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs Date: Wed, 15 Nov 2023 14:17:13 -0500 Message-ID: <20231115191631.936261545@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115191600.708733204@linuxfoundation.org> References: <20231115191600.708733204@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 6.5-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 08aeb69a78003..19071ff9eb753 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1521,9 +1521,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