usb: musb: core: drop redundant checks
Subsystems (2)
cover usb: musb: core: drop redundant checks
hw_ep can't be NULL but compared to NULL in 5.10 stable releases. The problem has been fixed by the following
patch which can be cleanly applied to the 5.10 branch.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
PATCH 1/1 usb: musb: core: drop redundant checks
From: Sergey Shtylyov <[email protected]>
commit b0ec7e55fce65f125bd1d7f02e2dc4de62abee34 upstream.
In musb_{save|restore}_context() the expression '&musb->endpoints[i]' just cannot be NULL, so the checks have no sense at all -- after dropping them, the local variables 'hw_ep' are no longer necessary, so drop them as well.
Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
--- drivers/usb/musb/musb_core.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/usb/musb/musb_core.c +2 -14
@@ -2673,13 +2673,7 @@ static void musb_save_context(struct musb *musb) musb->context.devctl =musb_readb (musb_base,MUSB_DEVCTL );for (i =0 ; i < musb->config->num_eps; ++i) { -struct musb_hw_ep *hw_ep; - - hw_ep = &musb->endpoints[i]; -if (!hw_ep) -continue ; - - epio = hw_ep->regs; + epio = musb->endpoints[i].regs;if (!epio)continue ;
@@ -2754,13 +2748,7 @@ static void musb_restore_context(struct musb *musb)musb_writeb (musb_base,MUSB_DEVCTL , musb->context.devctl);for (i =0 ; i < musb->config->num_eps; ++i) { -struct musb_hw_ep *hw_ep; - - hw_ep = &musb->endpoints[i]; -if (!hw_ep) -continue ; - - epio = hw_ep->regs; + epio = musb->endpoints[i].regs;if (!epio)continue ;
Signature · 1 line
2.25.1
Quoted 11 lines · Danila Chernetsov
From: Sergey Shtylyov <[email protected]>
commit
b0ec7e55fce65f125bd1d7f02e2dc4de62abee34upstream.In musb_{save|restore}_context() the expression '&musb->endpoints[i]' just cannot be NULL, so the checks have no sense at all -- after dropping them, the local variables '
hw_ep' are no longer necessary, so drop them as well.Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Quoted 7 lines
Signed-off-by Sergey Shtylyov <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Danila Chernetsov <[email protected]>--- drivers/usb/musb/musb_core.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
Hum... why do you need it it 5.10.y?
[...]
MBR, Sergey
Greg Kroah-Hartman
maintainerQuoted 3 lines · Danila Chernetsov
From: Sergey Shtylyov <[email protected]>
commit
b0ec7e55fce65f125bd1d7f02e2dc4de62abee34upstream.
Nit, trailing whitespace, please fix your editor to show this up easier.
Quoted 22 lines
In musb_{save|restore}_context() the expression '&musb->endpoints[i]' just cannot be NULL, so the checks have no sense at all -- after dropping them, the local variables '
hw_ep' are no longer necessary, so drop them as well.Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Danila Chernetsov <[email protected]>--- drivers/usb/musb/musb_core.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)drivers/usb/musb/musb_core.c +0
-0@@ -2673,13 +2673,7 @@ static void musb_save_context(struct musb *musb) musb->context.devctl =musb_readb (musb_base,MUSB_DEVCTL );
drivers/usb/musb/musb_core.c static void musb_save_context(struct musb *musb) · line 2676
Quoted 10 lines
drivers/usb/musb/musb_core.c +1
-7for (i =0 ; i < musb->config->num_eps; ++i) { -struct musb_hw_ep *hw_ep; - - hw_ep = &musb->endpoints[i]; -if (!hw_ep) -continue ; - - epio = hw_ep->regs; + epio = musb->endpoints[i].regs;
Why is this needed in the stable releases? It just seems to remove unused code, but does not change any logic at all, so why backport it?
thanks,
greg k-h
A message that is not in the archive (sent off-list or not yet received): [email protected]
Greg Kroah-Hartman
maintainerQuoted 1 line · listdansp
This patch was prepare in according to secure programming conception.
I do not understand what that means.
Quoted 1 line
In practice it indeed simply remove unused code.
Yes, it did, but why should that be added to a stable kernel tree?
Quoted 2 lines
If you're thinking, that this patch is useless, we don't insist on applying it.
I'm confused as to why you thought it should have been applied at all. Why did your testing deem it needed?
thanks,
greg k-h