From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Richard Acayan <mailingradian@gmail.com>
Cc: Marge Yang <marge.yang@tw.synaptics.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Vincent Huang <Vincent.Huang@tw.synaptics.com>,
david.chiu@tw.synaptics.com, derek.cheng@tw.synaptics.com,
sam.tsai@synaptics.com
Subject: Re: [PATCH V2] Input: synaptics-rmi4 - Supports to query DPM value.
Date: Tue, 3 Sep 2024 11:40:38 -0700 [thread overview]
Message-ID: <ZtdYJkU17y1iNsLG@google.com> (raw)
In-Reply-To: <ZtdQW7nqAOEJDNBN@radian>
On Tue, Sep 03, 2024 at 02:07:23PM -0400, Richard Acayan wrote:
> > + /* Use the Query DPM feature when the query register exists for resolution. */
> > + item = rmi_get_register_desc_item(&f12->query_reg_desc, RMI_F12_QUERY_RESOLUTION);
> > + if (item) {
> > + offset = rmi_register_desc_calc_reg_offset(&f12->query_reg_desc,
> > + RMI_F12_QUERY_RESOLUTION);
> > + query_dpm_addr = fn->fd.query_base_addr + offset;
> > + ret = rmi_read(fn->rmi_dev, query_dpm_addr, buf);
> > + if (ret < 0) {
> > + dev_err(&fn->dev, "Failed to read DPM value: %d\n", ret);
> > + return -ENODEV;
> > + }
> > + dpm_resolution = buf[0];
> > +
> > + sensor->x_mm = sensor->max_x / dpm_resolution;
> > + sensor->y_mm = sensor->max_y / dpm_resolution;
> > + } else {
> > + if (rmi_register_desc_has_subpacket(item, 3)) {
>
> The item variable is NULL in this branch, as it was overwritten just
> before the if statement.
>
> This patch causes a NULL pointer dereference:
Ugh, indeed. I guess the simplest way of fixing this would be:
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c
index fc2cc8e2b0ba..8246fe77114b 100644
--- a/drivers/input/rmi4/rmi_f12.c
+++ b/drivers/input/rmi4/rmi_f12.c
@@ -129,9 +129,8 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
* Use the Query DPM feature when the resolution query register
* exists.
*/
- item = rmi_get_register_desc_item(&f12->query_reg_desc,
- RMI_F12_QUERY_RESOLUTION);
- if (item) {
+ if (rmi_get_register_desc_item(&f12->query_reg_desc,
+ RMI_F12_QUERY_RESOLUTION)) {
offset = rmi_register_desc_calc_reg_offset(&f12->query_reg_desc,
RMI_F12_QUERY_RESOLUTION);
query_dpm_addr = fn->fd.query_base_addr + offset;
Could you please tell me if this works for you?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2024-09-03 18:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 8:36 [PATCH V2] Input: synaptics-rmi4 - Supports to query DPM value Marge Yang
2024-08-05 17:31 ` Dmitry Torokhov
2024-08-06 0:56 ` Derek Cheng
2024-09-03 18:07 ` Richard Acayan
2024-09-03 18:40 ` Dmitry Torokhov [this message]
2024-09-03 21:33 ` Richard Acayan
2024-09-03 22:03 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZtdYJkU17y1iNsLG@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=Vincent.Huang@tw.synaptics.com \
--cc=david.chiu@tw.synaptics.com \
--cc=derek.cheng@tw.synaptics.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailingradian@gmail.com \
--cc=marge.yang@tw.synaptics.com \
--cc=sam.tsai@synaptics.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).