From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3AB863BBFC0; Tue, 21 Jul 2026 21:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668043; cv=none; b=EQTpsxjdEUru7blUpH/DhzgUV1msxiAd0I335AObz9bEoYrjpRTUlnb3CiDPtLeNCTttWDJWlUJynniwYQNb6dO0DLeUKOKMQOypxkNZuujdxW3W0rxcdm1to0BzuzogyA5xiFZlVo7diiexPCC6hvKf04CbiRqu+X7vjmQ1FJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668043; c=relaxed/simple; bh=nAv9vXe1lw9VElZZXRjGkwC5OdBAUo/B8zJmARitWKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kTjVYNnVTNoJhV9QuxZqjHYbW6v0t82TWpvjWFtqh/JxyRZpEynlOmYSTOoS8nzK/lqxpMNXutAWVr6FCFOsj2dlmcWwWX6lrL6pY8lEe72Lnq0B2FVGpQQl5l+ppuoWjbIGSdAZNDafAEU0rWbxYMttMkoH4lR0DhXc0EGd4oY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2nbd+N62; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2nbd+N62" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AC521F000E9; Tue, 21 Jul 2026 21:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784668042; bh=O+IT884IUx65K8k0nspuAPeu0TthqzDOmxw14BZkSu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2nbd+N62b3MdASxTfxFpS2yX3jGPSzVLZZtPUYeFUX2pNlzxn77wlhT0Xui/ssZXp GVDD80KgIsPk16u21Q7lYVVsAk9QedjvGFYRR82hDdj9F2Ot0nwqR3P6C25K9p4Qs0 gPeQbYzO/Ako+uyjfVUf0/5x2lDuthkyqOqAel6Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joe Hattori , Johan Hovold , Wolfram Sang , Sasha Levin Subject: [PATCH 6.1 0026/1067] i2c: core: fix NULL-deref on adapter registration failure Date: Tue, 21 Jul 2026 17:10:27 +0200 Message-ID: <20260721152425.126300320@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold [ Upstream commit 2295d2bb101faa663fbc45fadbb3fec45f107441 ] If adapter registration ever fails the release callback would trigger a NULL-pointer dereference as the completion struct has not been initialised. Note that before the offending commit this would instead have resulted in a minor memory leak of the adapter name. Fixes: 3f8c4f5e9a57 ("i2c: core: fix reference leak in i2c_register_adapter()") Cc: stable@vger.kernel.org Cc: Joe Hattori Signed-off-by: Johan Hovold Signed-off-by: Wolfram Sang Stable-dep-of: ba14d7cf2fe7 ("i2c: core: fix adapter registration race") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core-base.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1557,7 +1557,7 @@ static int i2c_register_adapter(struct i res = device_register(&adap->dev); if (res) { pr_err("adapter '%s': can't register device (%d)\n", adap->name, res); - goto err_remove_irq_domain; + goto err_put_adap; } adap->debugfs = debugfs_create_dir(dev_name(&adap->dev), i2c_debugfs_root); @@ -1603,10 +1603,12 @@ static int i2c_register_adapter(struct i out_reg: i2c_deregister_clients(adap); debugfs_remove_recursive(adap->debugfs); + device_del(&adap->dev); +err_put_adap: init_completion(&adap->dev_released); - device_unregister(&adap->dev); + put_device(&adap->dev); wait_for_completion(&adap->dev_released); -err_remove_irq_domain: + i2c_host_notify_irq_teardown(adap); out_list: mutex_lock(&core_lock);