diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index dc398c6b7528..7d09256aca72 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -80,13 +80,17 @@ static ssize_t extts_fifo_show(struct device *dev, size_t qcnt; int cnt = 0; + spin_lock_irqsave(&ptp->tsevqs_lock, flags); cnt = list_count_nodes(&ptp->tsevqs); - if (cnt <= 0) + if (cnt <= 0) { + spin_unlock_irqrestore(&ptp->tsevqs_lock, flags); goto out; + } /* The sysfs fifo will always draw from the fist queue */ queue = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, qlist); + spin_unlock_irqrestore(&ptp->tsevqs_lock, flags); memset(&event, 0, sizeof(event)); spin_lock_irqsave(&queue->lock, flags);