This is a tough one since it is really hard to argue that either side benefitted much in the long run. However, it is probably correct to say that the US got more of a benefit from the Soviet invasion than the USSR did.
The reason for this is that the invasion of Afghanistan was a disaster for the USSR. It is typically said to be the USSR's Vietnam. It is described in this way because it sapped the Soviet economy and because it led to the deaths of thousands of Russian soldiers. One can argue that these costs of the invasion helped to lead to the collapse of the Soviet Union in the late 1980s.
However, the US eventually lost from this invasion as well. US support to insurgents fighting the Soviets helped to strengthen people such as Osama Bin Laden who would later hurt the US badly through terrorist actions and through the continuing fighting in Afghanistan today.