Assuming that the cavalry lack missile weapons, they wouldn't try to attack infantry armed with bayonet spears that can't be outflanked. Unless they heavily outnumbered the foot soldiers, and even then, while cavalry commanders weren't the brightest candles, they weren't that dim.
It would be a slaughter of horses gutted on bayonets - you do know that they were the primary targets. Hell, even without the stabbings, horses would be stumbling, twisting, colliding with each other at first contact, a bloody wreckage.
It's nothing like the fantasy of film. If you want a touch of the nightmare, do a Google video search of horse race accidents involving multiple mounts.
Frontal charges against a prepared defense are just about insane; in most wars.