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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0D0FC433F5 for ; Thu, 14 Oct 2021 14:59:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B34F360F36 for ; Thu, 14 Oct 2021 14:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233057AbhJNPBF (ORCPT ); Thu, 14 Oct 2021 11:01:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:44464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbhJNO7t (ORCPT ); Thu, 14 Oct 2021 10:59:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2964611ED; Thu, 14 Oct 2021 14:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634223462; bh=85Oe+SG4YAhT0uGSupy2UunOKLoMQHmt1FAIYw08P3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGyrAViFgpDeOJYSMyMg6rk5EcmiXkqxzzXqoPU4gZIQBN/4TQ/8yLBHIXrhP3sk/ aYQnwqopDamnN69GUor2niEuR3SCxgz2F5SFD8/wuyH8YVyTSGIPmSa3l1AfNI8pT7 J+t2Q8t/FSPW9pVmsHMpGFZm1cfJy7wjM65PwYu0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamie Iles , Mika Westerberg , Wolfram Sang , Sasha Levin Subject: [PATCH 4.14 23/33] i2c: acpi: fix resource leak in reconfiguration device addition Date: Thu, 14 Oct 2021 16:53:55 +0200 Message-Id: <20211014145209.574351338@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014145208.775270267@linuxfoundation.org> References: <20211014145208.775270267@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jamie Iles [ Upstream commit 6558b646ce1c2a872fe1c2c7cb116f05a2c1950f ] acpi_i2c_find_adapter_by_handle() calls bus_find_device() which takes a reference on the adapter which is never released which will result in a reference count leak and render the adapter unremovable. Make sure to put the adapter after creating the client in the same manner that we do for OF. Fixes: 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications") Signed-off-by: Jamie Iles Acked-by: Mika Westerberg [wsa: fixed title] Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 52ae674ebf5b..6f42856c1507 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -395,6 +395,7 @@ static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value, break; i2c_acpi_register_device(adapter, adev, &info); + put_device(&adapter->dev); break; case ACPI_RECONFIG_DEVICE_REMOVE: if (!acpi_device_enumerated(adev)) -- 2.33.0