Minimum connection time between Iberia flights at Madrid is 45 minutes (Schengen to Schengen), which you will be. You could get lucky and its next door, or it could be a little bit of a walk. There'll be no passport/security control.
Iberia generally have about 4 flights a day to Porto, so if...