Linux Input/HID development
 help / color / mirror / Atom feed
From: Jeff LaBundy <jeff@labundy.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, Jeff LaBundy <jeff@labundy.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] Input: iqs7222 - avoid dereferencing a NULL pointer
Date: Sun, 17 Apr 2022 16:41:32 -0500	[thread overview]
Message-ID: <20220417214132.497487-1-jeff@labundy.com> (raw)

Select callers of iqs7222_parse_props() do not expect a child node
to be derived and returned via pointer. As such, these callers set
**child_node to NULL. However, this pointer is dereferenced in all
cases.

To solve this problem, dereference the pointer only for cases that
expect a child node in the first place. In these cases, the caller
provides a valid pointer.

Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jeff LaBundy <jeff@labundy.com>
---
 drivers/input/misc/iqs7222.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c
index c0b273222092..6b4138771a3f 100644
--- a/drivers/input/misc/iqs7222.c
+++ b/drivers/input/misc/iqs7222.c
@@ -1534,8 +1534,8 @@ static int iqs7222_parse_props(struct iqs7222_private *iqs7222,
 			       enum iqs7222_reg_key_id reg_key)
 {
 	u16 *setup = iqs7222_setup(iqs7222, reg_grp, child_index);
-	struct fwnode_handle *reg_grp_node = *child_node;
 	struct i2c_client *client = iqs7222->client;
+	struct fwnode_handle *reg_grp_node;
 	char reg_grp_name[16];
 	int i;
 
@@ -1550,7 +1550,8 @@ static int iqs7222_parse_props(struct iqs7222_private *iqs7222,
 		 * for additional group-specific processing. In some cases, the
 		 * child node may have already been derived.
 		 */
-		if (*child_node)
+		reg_grp_node = *child_node;
+		if (reg_grp_node)
 			break;
 
 		snprintf(reg_grp_name, sizeof(reg_grp_name), "%s-%d",
-- 
2.25.1


             reply	other threads:[~2022-04-17 21:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 21:41 Jeff LaBundy [this message]
2022-04-17 23:05 ` [PATCH] Input: iqs7222 - avoid dereferencing a NULL pointer 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=20220417214132.497487-1-jeff@labundy.com \
    --to=jeff@labundy.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /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