All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect()
@ 2019-12-17  9:50 Jia-Ju Bai
  2019-12-17  9:59 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Jia-Ju Bai @ 2019-12-17  9:50 UTC (permalink / raw)
  To: b-liu, gregkh; +Cc: linux-usb, linux-kernel, Jia-Ju Bai

In musb_handle_intr_connect(), musb->hcd should be non-null, 
so the check of musb->hcd on line 783 could be dropped.

Thank Greg for good advice.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/usb/musb/musb_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 15cca912c53e..ce57f253a8e1 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -780,8 +780,7 @@ static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb)
 		musb_dbg(musb, "HNP: CONNECT, now b_host");
 b_host:
 		musb->xceiv->otg->state = OTG_STATE_B_HOST;
-		if (musb->hcd)
-			musb->hcd->self.is_b_host = 1;
+		musb->hcd->self.is_b_host = 1;
 		del_timer(&musb->otg_timer);
 		break;
 	default:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect()
  2019-12-17  9:50 [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect() Jia-Ju Bai
@ 2019-12-17  9:59 ` Greg KH
  2019-12-17 12:27   ` Jia-Ju Bai
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2019-12-17  9:59 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: b-liu, linux-usb, linux-kernel

On Tue, Dec 17, 2019 at 05:50:23PM +0800, Jia-Ju Bai wrote:
> In musb_handle_intr_connect(), musb->hcd should be non-null, 
> so the check of musb->hcd on line 783 could be dropped.

Have you verified that this is always the case?  How did you do that?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect()
  2019-12-17  9:59 ` Greg KH
@ 2019-12-17 12:27   ` Jia-Ju Bai
  2019-12-17 19:15     ` Bin Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Jia-Ju Bai @ 2019-12-17 12:27 UTC (permalink / raw)
  To: Greg KH; +Cc: b-liu, linux-usb, linux-kernel



On 2019/12/17 17:59, Greg KH wrote:
> On Tue, Dec 17, 2019 at 05:50:23PM +0800, Jia-Ju Bai wrote:
>> In musb_handle_intr_connect(), musb->hcd should be non-null,
>> so the check of musb->hcd on line 783 could be dropped.
> Have you verified that this is always the case?  How did you do that?

Ah, so sorry, I misunderstood your last message...
I have not verified it, but I thought you made sure of it from your last 
message, sorry...

In my opinion, adding an if check is safer, as shown in my last patch:
"usb: musb: Fix a possible null-pointer dereference in 
musb_handle_intr_connect()"

I recall that Bin Liu has applied my last patch:
https://patchwork.kernel.org/patch/11283007/

Maybe we can listen to his opinion or other people's opinions?


Best wishes,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect()
  2019-12-17 12:27   ` Jia-Ju Bai
@ 2019-12-17 19:15     ` Bin Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Bin Liu @ 2019-12-17 19:15 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: Greg KH, linux-usb, linux-kernel

Hi,

On Tue, Dec 17, 2019 at 08:27:09PM +0800, Jia-Ju Bai wrote:
> 
> 
> On 2019/12/17 17:59, Greg KH wrote:
> > On Tue, Dec 17, 2019 at 05:50:23PM +0800, Jia-Ju Bai wrote:
> > > In musb_handle_intr_connect(), musb->hcd should be non-null,
> > > so the check of musb->hcd on line 783 could be dropped.
> > Have you verified that this is always the case?  How did you do that?
> 
> Ah, so sorry, I misunderstood your last message...
> I have not verified it, but I thought you made sure of it from your last
> message, sorry...
> 
> In my opinion, adding an if check is safer, as shown in my last patch:
> "usb: musb: Fix a possible null-pointer dereference in
> musb_handle_intr_connect()"
> 
> I recall that Bin Liu has applied my last patch:
> https://patchwork.kernel.org/patch/11283007/
> 
> Maybe we can listen to his opinion or other people's opinions?

The code path this patch touches is in OTG_STATE_B_WAIT_ACON branch,
which is part of the OTG HNP handling, but OTG protocol support has been
disabled since commit 0a9134bd733b, so technically this code path won't
be reached.

Let's not bother with this ->hcd pointer check, and wait for OTG code
cleanup in this driver.

-Bin.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-17 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17  9:50 [PATCH] usb: musb: Remove unnecessary check of musb->hcd in musb_handle_intr_connect() Jia-Ju Bai
2019-12-17  9:59 ` Greg KH
2019-12-17 12:27   ` Jia-Ju Bai
2019-12-17 19:15     ` Bin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.