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 E15B7472F85; Tue, 21 Jul 2026 20:12:04 +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=1784664726; cv=none; b=YoLMM+68M1Q7xwnQWlLqazgXYm7HwrKwUpXlbGxsl02Rr+FudAl7Om/R0taSZlFcOmukidTblEbc1XxkLcdj2OwTYG7Jmg+qOE1Zj1LIjD35cKSzwVQ1KXRvbKgdkOcEI4TJ5wc4mXnfdlw/oN3cqwTIYG5ZUDsobpKfdnQxFWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784664726; c=relaxed/simple; bh=Fl0HicHZbWoAm1zz44t5356jYMzPv+qqzQcOxlW4fNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D9Me1F7+Z1Dnr/vy6d7el+mdoMsb1zdaTCPlWNS8OQyXRWVRje5wjyKPhN+AEA5VOufDImHWB9IsxBL+iLDuZAQjWIPlDBS0n5I8Z8wBt5BKA75D8jf6t4R/oBGfUpkw4AofnDto1lrrsTSKZt/JDjr3/x6ynP57p+3T39ygk3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SOm7GMMW; 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="SOm7GMMW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C891F000E9; Tue, 21 Jul 2026 20:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784664724; bh=ivnL22XMjyRxXmPuezyuHO5fxJ1vbVTNt5WNMD6mR9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SOm7GMMWRxO7e/I/K5Gtclut2YbfI5yPSiT2090e+KtRhl4emm5SFX3s4U5fgfTqK NEPA+Cnr0B50ulvKs5olNU2n8SOfcBnP7G/ba0Lc8CB892zaUliZ5BsfRxL9ivQOI9 JDt6TSCJ895H6X1eRP/Dm0O79IMEbtdQIAsdWnfc= 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.6 0034/1266] i2c: core: fix NULL-deref on adapter registration failure Date: Tue, 21 Jul 2026 17:07:51 +0200 Message-ID: <20260721152442.560996319@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-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 @@ -1552,7 +1552,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); @@ -1598,10 +1598,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);