mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] net: ti: possible deadlock in cpts_ptp_gettimeex() and cpts_overflow_check()
@ 2022-02-07 14:43 Jia-Ju Bai
  0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2022-02-07 14:43 UTC (permalink / raw)
  To: davem, kuba, grygorii.strashko, vladimir.oltean, vigneshr, yangyingliang
  Cc: netdev, linux-kernel

Hello,

My static analysis tool reports a possible deadlock in the ti driver in 
Linux 5.16:

cpts_ptp_gettimeex()
   mutex_lock(&cpts->ptp_clk_mutex); --> Line 260 (Lock A)
   cpts_update_cur_time()
     wait_for_completion_timeout(&cpts->ts_push_complete, HZ); --> Line 
210 (Wait X)

cpts_overflow_check()
   mutex_lock(&cpts->ptp_clk_mutex); --> Line 411 (Lock A)
   cpts_update_cur_time()
     cpts_fifo_read()
       complete(&cpts->ts_push_complete); --> Line 142 (Wake X)

When cpts_ptp_gettimeex() is executed, "Wait X" is performed by holding 
"Lock A". If cpts_overflow_check() is executed at this time, "Wake X" 
cannot be performed to wake up "Wait X" in cpts_ptp_gettimeex(), because 
"Lock A" has been already hold by cpts_ptp_gettimeex(), causing a 
possible deadlock.
I find that "Wait X" is performed with a timeout, to relieve the 
possible deadlock; but I think this timeout can cause inefficient execution.

I am not quite sure whether this possible problem is real and how to fix 
it if it is real.
Any feedback would be appreciated, thanks :)


Best wishes,
Jia-Ju Bai


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-07 15:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 14:43 [BUG] net: ti: possible deadlock in cpts_ptp_gettimeex() and cpts_overflow_check() Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®