Skip to contentSkip to conversation

Input: iqs7222 - avoid dereferencing a NULL pointer

PATCH Applied Jeff LaBundy 2 participants 2 messages Apr 17, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: iqs7222 - avoid dereferencing a NULL pointer

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")
---
 drivers/input/misc/iqs7222.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/input/misc/iqs7222.c +3 -2
index c0b273222092..6b4138771a3f 100644
@@ -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",
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Jeff LaBundy

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.

Quoted 7 lines

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")

Applied, thank you.

Signature · 1 line
Dmitry