A common misconception is that you are legally liable for every bullet you fire in a self defense situation. That is not exactly the case. The answer to this is called the doctrine of transferred intent.
The simple reason is that the shooter (self-defense actor) was not the proximate cause of the harm to the innocent bystander. Although that may seem counter intuitive to say (given he was the one who actually fired the gun), it was in fact the attacker provoking the self-defense actor who caused the bystander harm.
In the legal world this is called the doctrine of transferred intent. It has been recited in numerous cases (see State v. Green, 157 W. Va. 1031, 1034, 206 S.E.2d 923, 926 (1974)).
I don’t want to steal any more of attorney Phil Nelson’s thunder or expertise on this. Check out this article at his excellent self defense blog here. Know the law. Stay out of jail.