* Re: [PATCH net-XXX] net: dsa: qca8k: uninitialized variable in hw_control_get()
2023-06-12 7:20 [PATCH net-XXX] net: dsa: qca8k: uninitialized variable in hw_control_get() Dan Carpenter
@ 2023-06-11 16:04 ` Christian Marangi
2023-06-12 8:42 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Christian Marangi @ 2023-06-11 16:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Pavel Machek, netdev,
kernel-janitors
On Mon, Jun 12, 2023 at 10:20:55AM +0300, Dan Carpenter wrote:
> The caller, netdev_trig_activate(), passes an uninitialized value for
> *rules. This function sets bits to one but it doesn't zero out any
> bits so there is a potential for uninitialized data to be used.
> Zero out the *rules at the start of the function.
>
> Fixes: e0256648c831 ("net: dsa: qca8k: implement hw_control ops")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thanks for the fix but I wonder if this should be better fixed in
netdev_trig_activate? By setting the mode as 0 directly there?
I assume other dev implementing the get ops would do the same mistake.
--
Ansuel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-XXX] net: dsa: qca8k: uninitialized variable in hw_control_get()
@ 2023-06-12 7:20 Dan Carpenter
2023-06-11 16:04 ` Christian Marangi
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-06-12 7:20 UTC (permalink / raw)
To: Christian Marangi
Cc: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Pavel Machek, netdev,
kernel-janitors
The caller, netdev_trig_activate(), passes an uninitialized value for
*rules. This function sets bits to one but it doesn't zero out any
bits so there is a potential for uninitialized data to be used.
Zero out the *rules at the start of the function.
Fixes: e0256648c831 ("net: dsa: qca8k: implement hw_control ops")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/dsa/qca/qca8k-leds.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c
index 6f02029b454b..772478156e4e 100644
--- a/drivers/net/dsa/qca/qca8k-leds.c
+++ b/drivers/net/dsa/qca/qca8k-leds.c
@@ -304,6 +304,8 @@ qca8k_cled_hw_control_get(struct led_classdev *ldev, unsigned long *rules)
u32 val;
int ret;
+ *rules = 0;
+
/* With hw control not active return err */
if (!qca8k_cled_hw_control_status(ldev))
return -EINVAL;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-XXX] net: dsa: qca8k: uninitialized variable in hw_control_get()
2023-06-11 16:04 ` Christian Marangi
@ 2023-06-12 8:42 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-06-12 8:42 UTC (permalink / raw)
To: Christian Marangi
Cc: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Pavel Machek, netdev,
kernel-janitors
The net-XXX in the subject was supposed to be net-next btw. I did check
that it only applied to net-next but I messed up the subject... :/
On Sun, Jun 11, 2023 at 06:04:31PM +0200, Christian Marangi wrote:
> On Mon, Jun 12, 2023 at 10:20:55AM +0300, Dan Carpenter wrote:
> > The caller, netdev_trig_activate(), passes an uninitialized value for
> > *rules. This function sets bits to one but it doesn't zero out any
> > bits so there is a potential for uninitialized data to be used.
> > Zero out the *rules at the start of the function.
> >
> > Fixes: e0256648c831 ("net: dsa: qca8k: implement hw_control ops")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> Thanks for the fix but I wonder if this should be better fixed in
> netdev_trig_activate? By setting the mode as 0 directly there?
>
> I assume other dev implementing the get ops would do the same mistake.
Yes. You're obviously right on this. I'm not sure what I was thinking.
I will resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-12 8:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 7:20 [PATCH net-XXX] net: dsa: qca8k: uninitialized variable in hw_control_get() Dan Carpenter
2023-06-11 16:04 ` Christian Marangi
2023-06-12 8:42 ` Dan Carpenter
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).