Both of them are correct and it's the speaker's choice which one to use. Native-speakers who are a bit older generally use 'were' (the subjunctive), but younger people often choose 'was'.
NOTE: we only tend to use the subjunctive with the verb 'be', and we use past simple with other verbs.
If only I HAD more free time.
If only you DIDN'T live in Australia!
If only he WERE older. If only he WAS older.