In general, pressures on prices and wages brought about by supply and demand could push an economy back towards potential output regardless of whether the economy is experiencing a recessionary gap or an inflationary gap.
If the economy is in recession, the aggregate demand drops. When demand drops, the prices of goods will have to go down. According to classical economics at least, the price of labor (wages) will go down as well. This will gradually push the economy back to its potential output.
If the economy is experiencing excessive inflation, aggregate demand has likely risen. As demand rises, the prices of goods tend to rise. Classical economics holds that the price of labor will rise as well. These increases will gradually reduce aggregate demand and return the economy to its potential level of output, which is the level of output possible if all resources are used fully.