Skip to content

Commit

Permalink
FIXED: usb/dwhcixferstagedata: Asserts on frame overrun
Browse files Browse the repository at this point in the history
There seem to be USB devices, which send more data than it is expected.
This was leading to a failed assertion. This should prevent a system
crash by faking a frame overrun error, which should be handled by the
upper layers.

See: probonopd/MiniDexed#39
  • Loading branch information
rsta2 committed Mar 15, 2022
1 parent bd46bf0 commit 612334f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/usb/dwhcixferstagedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// dwhcixferstagedata.cpp
//
// Circle - A C++ bare metal environment for Raspberry Pi
// Copyright (C) 2014-2021 R. Stange <rsta2@o2online.de>
// Copyright (C) 2014-2022 R. Stange <rsta2@o2online.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -221,7 +221,18 @@ void CDWHCITransferStageData::TransactionComplete (u32 nStatus, u32 nPacketsLeft
m_pEndpoint->SkipPID (nPacketsTransfered, m_bStatusStage);
}

assert (nPacketsTransfered <= m_nPackets);
// this shouldn't but does happen with some devices
if (nPacketsTransfered > m_nPackets)
{
CLogger::Get ()->Write ("udata", LogWarning, "Frame overrun forced");

m_nTransactionStatus |= DWHCI_HOST_CHAN_INT_FRAME_OVERRUN;
m_nErrorCount = MAX_BULK_TRIES+1;
m_nPackets = 0;

return;
}

m_nPackets -= nPacketsTransfered;

if (!m_bSplitTransaction)
Expand Down

0 comments on commit 612334f

Please sign in to comment.