Flying from Barcelona to Granada will work fine. That's a good idea if those are the two cities you most want to see.
The issue is with getting from Granada to Portugal. There is no rail service beyond Seville, so you'd probably need to take a bus from there to Faro. It will mean a bus from Granada to Antequera, a train from Antequera to Seville, a bus from Seville to (I think) Faro, then a bus or train to wherever you really want to go (which is likely not Faro).
What it comes down to is that it's really not a good idea to try to combine Spain and Portugal when you don't have much time, unless you just want to do a two-city trip (Madrid/Lisbon or Barcelona/Lisbon) and fly between the two cities.
Have you already bought your airline tickets? If not, I'd definitely drop Portugal from this trip. By the time you deal with difficult ground transportation from Granada to an attractive place in the Algarve (Tavira and Lagos seem to be the most frequently recommended these days) and allow time for getting to Lisbon the day before your flight home, your 3 days for Portugal will have turned into one day. Those last three days will be mostly about transportation, not sightseeing. Frankly, this doesn't sound like the kind of itinerary that would appeal to someone who like the amenities.
It's just a guess, but I'm betting you don't have much time scheduled for Barcelona, either, so I'd shift that Portugal time to Barcelona and figure out a way to fly home from Malaga.
It would be easier for us to make suggestions if we had a picture of your entire trip.