Skip to contentSkip to conversation

usb: typec: tipd: Prevent uninitialized event{1,2} in IRQ handler

PATCH In review Sven Peter 4 participants 4 messages Nov 2, 2022 – Nov 3, 2022

Subsystems (2)
lore
Share & tools
lore

Sven Peter

author
#0 lore raw

PATCH 1/1 usb: typec: tipd: Prevent uninitialized event{1,2} in IRQ handler

If reading TPS_REG_INT_EVENT1/2 fails in the interrupt handler event1 and event2 may be uninitialized when they are used to determine IRQ_HANDLED vs. IRQ_NONE in the error path.

Fixes c7260e29dd20 ("usb: typec: tipd: Add short-circuit for no irqs")
Fixes 45188f27b3d0 ("usb: typec: tipd: Add support for Apple CD321X")
---
 drivers/usb/typec/tipd/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +3 -3
index b637e8b378b3..2a77bab948f5 100644
@@ -474,7 +474,7 @@ static void tps6598x_handle_plug_event(struct tps6598x *tps, u32 status)
 static irqreturn_t cd321x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event;
+	u64 event = 0;
 	u32 status;
 	int ret;
 
@@ -519,8 +519,8 @@ static irqreturn_t cd321x_interrupt(int irq, void *data)
 static irqreturn_t tps6598x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event1;
-	u64 event2;
+	u64 event1 = 0;
+	u64 event2 = 0;
 	u32 status;
 	int ret;
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Sven Peter

If reading TPS_REG_INT_EVENT1/2 fails in the interrupt handler event1 and event2 may be uninitialized when they are used to determine IRQ_HANDLED vs. IRQ_NONE in the error path.

Fixes c7260e29dd20 ("usb: typec: tipd: Add short-circuit for no irqs")
Fixes 45188f27b3d0 ("usb: typec: tipd: Add support for Apple CD321X")
Quoted 32 lines
---
 drivers/usb/typec/tipd/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +3 -4
index b637e8b378b3..2a77bab948f5 100644
@@ -474,7 +474,7 @@ static void tps6598x_handle_plug_event(struct tps6598x *tps, u32 status)
 static irqreturn_t cd321x_interrupt(int irq, void *data)
 {
        struct tps6598x *tps = data;
-       u64 event;
+       u64 event = 0;
        u32 status;
        int ret;
 
@@ -519,8 +519,8 @@ static irqreturn_t cd321x_interrupt(int irq, void *data)
 static irqreturn_t tps6598x_interrupt(int irq, void *data)
 {
        struct tps6598x *tps = data;
-       u64 event1;
-       u64 event2;
+       u64 event1 = 0;
+       u64 event2 = 0;
        u32 status;
        int ret;
 
--

2.25.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Sven Peter

Hi,

Quoted 25 lines · Sven Peter

If reading TPS_REG_INT_EVENT1/2 fails in the interrupt handler event1 and event2 may be uninitialized when they are used to determine IRQ_HANDLED vs. IRQ_NONE in the error path.

Fixes c7260e29dd20 ("usb: typec: tipd: Add short-circuit for no irqs")
Fixes 45188f27b3d0 ("usb: typec: tipd: Add support for Apple CD321X")
---
 drivers/usb/typec/tipd/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +1 -1
index b637e8b378b3..2a77bab948f5 100644
@@ -474,7 +474,7 @@ static void tps6598x_handle_plug_event(struct tps6598x *tps, u32 status)
 static irqreturn_t cd321x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event;
+	u64 event = 0;
 	u32 status;
 	int ret;
 

drivers/usb/typec/tipd/core.c static irqreturn_t cd321x_interrupt(int irq, void *data) · line 525

Quoted 9 lines
drivers/usb/typec/tipd/core.c +2 -2
@@ -519,8 +519,8 @@ static irqreturn_t cd321x_interrupt(int irq, void *data)
 static irqreturn_t tps6598x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event1;
-	u64 event2;
+	u64 event1 = 0;
+	u64 event2 = 0;
 	u32 status;
 	int ret;

Cheers,
-- Guido

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Sven Peter
Quoted 7 lines · Sven Peter

If reading TPS_REG_INT_EVENT1/2 fails in the interrupt handler event1 and event2 may be uninitialized when they are used to determine IRQ_HANDLED vs. IRQ_NONE in the error path.

Fixes c7260e29dd20 ("usb: typec: tipd: Add short-circuit for no irqs")
Fixes 45188f27b3d0 ("usb: typec: tipd: Add support for Apple CD321X")
Quoted 18 lines
---
 drivers/usb/typec/tipd/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +1 -1
index b637e8b378b3..2a77bab948f5 100644
@@ -474,7 +474,7 @@ static void tps6598x_handle_plug_event(struct tps6598x *tps, u32 status)
 static irqreturn_t cd321x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event;
+	u64 event = 0;
 	u32 status;
 	int ret;
 

drivers/usb/typec/tipd/core.c static irqreturn_t cd321x_interrupt(int irq, void *data) · line 526

Quoted 10 lines
drivers/usb/typec/tipd/core.c +2 -2
@@ -519,8 +519,8 @@ static irqreturn_t cd321x_interrupt(int irq, void *data)
 static irqreturn_t tps6598x_interrupt(int irq, void *data)
 {
 	struct tps6598x *tps = data;
-	u64 event1;
-	u64 event2;
+	u64 event1 = 0;
+	u64 event2 = 0;
 	u32 status;
 	int ret;
 

thanks,

Signature · 1 line
heikki