From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1E1E51DFD1; Tue, 8 Oct 2024 13:04:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728392674; cv=none; b=qy2iaXuS5buySObD8uv17Hx0cSmLynB4KK3HMOVsL6/qdDrwPSvqYgKHp+vbNMPnflOnn/I7SBJtT0Dwnl26qqc+vZ/tUYv+xSXF91fI8FSmjqZV/8ZPydmPBh3NUocPUTkhzwkNkDTmFjPF9jup1697DFHbJW88XSs0IWxvTjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728392674; c=relaxed/simple; bh=Na6RJVXA+EVWWbD3/1tUldjTdUmc6Nw+zQfgjZhrgqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KJYPgwkzyu6B8/GpsvAuGvP0tUw54e+kx808hTiOnxJoS0TfCogk41ANgUzXuwPMGB4kqnbcJVITcBvv1Z8nyD9K22fTV+1EZ/ro1GCD7W+/GfF2D84BeqYQEVAZsWPm32Or8zq3uS0lmDZWYRmCwtVERN44VJhl+BffhbvF9bY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pJhknUuF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pJhknUuF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81414C4CECC; Tue, 8 Oct 2024 13:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728392674; bh=Na6RJVXA+EVWWbD3/1tUldjTdUmc6Nw+zQfgjZhrgqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJhknUuFUw/PNvJmDCjrhDJRkqOzOXRTNCtK3piU2+aEEYjqbUJ+sLyPUzipVFTvv v5L0FRSNoiapFJv3d22FNHa5Wak4hmgPq/1OFNWGJY27mxGI5wjAawaY4JzeMrpig4 rfN3hkOfrx0qr7+LVeBp19uunz54Axi1M95hR8tc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nuno Sa , Dmitry Torokhov Subject: [PATCH 6.11 486/558] Input: adp5589-keys - fix NULL pointer dereference Date: Tue, 8 Oct 2024 14:08:36 +0200 Message-ID: <20241008115721.359501131@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115702.214071228@linuxfoundation.org> References: <20241008115702.214071228@linuxfoundation.org> User-Agent: quilt/0.67 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.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nuno Sa commit fb5cc65f973661241e4a2b7390b429aa7b330c69 upstream. We register a devm action to call adp5589_clear_config() and then pass the i2c client as argument so that we can call i2c_get_clientdata() in order to get our device object. However, i2c_set_clientdata() is only being set at the end of the probe function which means that we'll get a NULL pointer dereference in case the probe function fails early. Fixes: 30df385e35a4 ("Input: adp5589-keys - use devm_add_action_or_reset() for register clear") Signed-off-by: Nuno Sa Link: https://lore.kernel.org/r/20241001-b4-dev-adp5589-fw-conversion-v1-1-fca0149dfc47@analog.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/adp5589-keys.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -936,10 +936,9 @@ static int adp5589_keypad_add(struct adp static void adp5589_clear_config(void *data) { - struct i2c_client *client = data; - struct adp5589_kpad *kpad = i2c_get_clientdata(client); + struct adp5589_kpad *kpad = data; - adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); + adp5589_write(kpad->client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); } static int adp5589_probe(struct i2c_client *client) @@ -983,7 +982,7 @@ static int adp5589_probe(struct i2c_clie } error = devm_add_action_or_reset(&client->dev, adp5589_clear_config, - client); + kpad); if (error) return error; @@ -1010,8 +1009,6 @@ static int adp5589_probe(struct i2c_clie if (error) return error; - i2c_set_clientdata(client, kpad); - dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); return 0; }