Skip to content

Commit

Permalink
In practice we can have two consecutive x8h7_pkt_send_defer calls, fi…
Browse files Browse the repository at this point in the history
…xed mutex handling
  • Loading branch information
MaxPayne86 committed Apr 12, 2024
1 parent d0c69cb commit d1a6b67
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions x8h7_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,8 @@ int x8h7_pkt_send_defer(uint8_t peripheral, uint8_t opcode, uint16_t size, void
ret = x8h7_pkt_enq(peripheral, opcode, size, data);
if (ret < 0) {
printk("x8h7_pkt_enq failed with %d", ret);
mutex_unlock(&spidev->lock);
return ret;
}
/* No mutex unlocking here ... */

mutex_unlock(&spidev->lock);
return ret;
}
EXPORT_SYMBOL_GPL(x8h7_pkt_send_defer);
Expand All @@ -250,18 +247,15 @@ EXPORT_SYMBOL_GPL(x8h7_pkt_send_defer);
*/
int x8h7_pkt_send_now(void)
{
/* No mutex locking here ... */
struct spidev_data *spidev = x8h7_spidev;
int ret;

mutex_lock(&spidev->lock);
ret = x8h7_pkt_send();
if (ret < 0) {
printk("x8h7_pkt_send failed with %d", ret);
mutex_unlock(&spidev->lock);
return ret;
}
mutex_unlock(&spidev->lock);

return ret;
}
EXPORT_SYMBOL_GPL(x8h7_pkt_send_now);
Expand Down

0 comments on commit d1a6b67

Please sign in to comment.