From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4CF9C54FB9 for ; Wed, 15 Nov 2023 19:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235331AbjKOTs7 (ORCPT ); Wed, 15 Nov 2023 14:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235340AbjKOTs7 (ORCPT ); Wed, 15 Nov 2023 14:48:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF53F1AC for ; Wed, 15 Nov 2023 11:48:55 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33C9FC433CA; Wed, 15 Nov 2023 19:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700077735; bh=eObYfPn3v3dmEr5a09fWg2veb5co5Tvl7V0vYUwjVYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeTe54EtQZHwBqvtvjMuyorM3aBpNdR84C+hRQEf7oxsVy/SJtXPe1X3f4R5Ep3TQ 7M3WjiyVFJoAF37XQFH/PFRVVfAFtSB/nbUOs+cAovCvgjCzY+bkpLDQAz8kBI8nf4 Y/6U8px6Xwf6+0yRLqFXidazP3hcaApx1MOAQ/EA= 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.6 486/603] i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs Date: Wed, 15 Nov 2023 14:17:11 -0500 Message-ID: <20231115191645.985435859@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115191613.097702445@linuxfoundation.org> References: <20231115191613.097702445@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.6-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 87283e4a46076..0e9ff5500a777 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1525,9 +1525,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