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 0611E44AB62; Tue, 21 Jul 2026 21:56:38 +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=1784670999; cv=none; b=GU7lnvEMs14rRSM2uAg0RzuJTUh0KzSVBRvmPS6AqWuowppAzopMnrhXFMo1VBfM53oq9TvMfiqDtHheNz3zIPvK1I50aatayrtnpPwZELk3dp65Hq/rTPFye6tW8MzpwFvghQoZYwvSuVpDn7ZZoxrkBmxGFaHo7gXZDQaEmvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670999; c=relaxed/simple; bh=Nno8b+7wIGG+VBLXmJV3Iaj38Q8DO+fwGshxGWPHFKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQH3mey6EOfF+UxeGK8O8UyvVPli0S32TQNass69+DYD+NfXHAq8XWwPMMs64wUSRTR5Xwr73Cjf2VHrF3hH3fYQYohKcbgbMWNqB9zrmX7ZWoGC8cjx3FtszprsMkRLtBtdZUQCBbrAggSj4Oxexw7+rGpzUP5xlC+wcwQ5P2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wF/f4Rqg; 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="wF/f4Rqg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C7081F000E9; Tue, 21 Jul 2026 21:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670997; bh=omA/Bwgvkx842fcHJpiSAjYGpmfz15ie1uZzphZQvvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wF/f4RqgCvI+pKUZVzz81bsNqUVeuFbsKCghx2PmcEVantL9GSoL61WeIpi0TDFW9 ruCGC5sDnsQus3cIi0N+47+Zj03P2txCk+Oiw5wcpQp+hrtCOMGSY3bDJ+kcjKb9O6 NTLu05445pwAGie1/MgM73KPssqiA6fXy57aq7Xk= 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 5.15 037/843] i2c: core: fix NULL-deref on adapter registration failure Date: Tue, 21 Jul 2026 17:14:32 +0200 Message-ID: <20260721152406.809114268@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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 5.15-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 @@ -1555,7 +1555,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); @@ -1600,10 +1600,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);