
198 Ill. App.3d 521 (1990)
555 N.E.2d 1275
THE PEOPLE OF THE STATE OF ILLINOIS, Plaintiff-Appellee,
v.
MARK MAPPS, Defendant-Appellant.
No. 5-89-0285.
Illinois Appellate Court  Fifth District.
Opinion filed June 19, 1990.
*522 Daniel M. Kirwan and Janet L. Gandy, both of State Appellate Defender's Office, of Mt. Vernon, for appellant.
Charles Garnati, State's Attorney, of Marion (Kenneth R. Boyle, Stephen Norris, and Scott A. Manuel, all of State's Attorneys Appellate Prosecutor's Office, of counsel), for the People.
Affirmed as modified.
JUSTICE HOWERTON delivered the opinion of the court:
We affirm defendant's conviction entered on his open plea of guilty to unlawful possession of a controlled substance and unlawful possession of cannabis, but the sentence is modified by reducing the sentence for possession of a controlled substance from five years' to three years' imprisonment.
*523 Prior to accepting defendant's plea, the circuit court of Williamson County informed defendant that the controlled-substance charge was a Class 4 felony, and that he could be sentenced to one to three years' imprisonment, but did not inform defendant that he could receive an extended term.
At defendant's sentencing hearing, the State argued for an extended-term sentence on the controlled-substance conviction because defendant had a prior burglary conviction. The court sentenced defendant to an extended term of five years' imprisonment on the controlled-substance conviction, and 364 days on the cannabis conviction, with the sentences to run concurrently.
Defendant's motion to withdraw his guilty plea was denied and defendant appeals, claiming that his sentence of five years' imprisonment must be vacated because he was not informed that he was eligible for an extended-term sentence before his guilty plea was accepted.
The State argues that defendant has waived appellate review of this issue because he did not include the propriety of the extended term in his motion to withdraw his plea of guilty.
 1 Section 5-8-2(b) of the Unified Code of Corrections governs the applicability of extended-term sentences. It provides:
"If the conviction was by plea, it shall appear on the record that the plea was entered with the defendant's knowledge that a sentence under this Section was a possibility. If it does not so appear on the record, the defendant shall not be subject to such a sentence unless he is first given an opportunity to withdraw his plea without prejudice." Ill. Rev. Stat. 1989, ch. 38, par. 1005-8-2(b).
Defendant was not informed that he could receive an extended-term sentence when his plea was accepted. The record shows that the first defendant heard of the possibility of being given an extended term was when he was sentenced.
The critical question, therefore, is whether defendant had an opportunity to withdraw his guilty plea prior to sentencing. If he did have an opportunity to withdraw his plea, the sentence is proper under section 5-8-2(b). (Ill. Rev. Stat. 1989, ch. 38, par. 1005-8-2(b).) If, however, defendant did not have an opportunity to withdraw his plea, we cannot find waiver and we must vacate the portion of the sentence that is void.
 2 A review of the record establishes that defendant was never afforded an opportunity to withdraw his plea of guilty before he was sentenced. Therefore, the statute provides that defendant is not eligible for an extended-term sentence.
*524 Questions then arise: What is to become of the conviction? Is it wiped out and the case remanded for a fresh start? Or, is the conviction to be affirmed and the sentence to be modified by reducing it?
 3, 4 In Illinois, where a sentence that is greater than permitted by statute is imposed, the sentence is not void; rather, only the excess portion of the sentence is void. (In re T.E. (1981), 85 Ill.2d 326, 333, 423 N.E.2d 910, 913; People v. Perruquet (1989), 181 Ill. App.3d 660, 663, 537 N.E.2d 351, 353.) The excess here is two years: This excess is void. The maximum sentence available here is three years' imprisonment. (Ill. Rev. Stat. 1989, ch. 38, par. 1005-8-1(a)(7).) Section 5-8-2(b) (Ill. Rev. Stat. 1989, ch. 38, par. 1005-8-2(b)) requires that defendant's five-year sentence be modified accordingly by reducing it to three years. See Supreme Court Rule 615(b) (107 Ill.2d 615(b)).
 5 As to the State's argument that this issue is waived, we noted in People v. Perruquet (1989), 181 Ill. App.3d 660, 537 N.E.2d 351, that:
"To the extent that the excess sentence is void, the judgment is void also, and a void judgment may be vacated at any time. Given this, we believe that petitioner's attack on his extended-term sentence is, in effect, an attack on a void judgment. * * *
* * *
* * * [T]he argument that a judgment in a criminal case is void is, as we have indicated, a matter which can be raised at any time. This is so regardless of whether the argument was properly preserved for review." Perruquet, 181 Ill. App.3d at 663-64, 537 N.E.2d at 353-54.
Therefore, since the excess portion of an extended-term sentence imposed in violation of a statute is void, the excess portion may be challenged on appeal irrespective of whether this issue was included in a motion to withdraw a guilty plea.
Therefore, defendant's convictions for unlawful possession of a controlled substance and unlawful possession of cannabis are affirmed. Defendant's sentence for his conviction of unlawful possession of a controlled substance is modified and reduced to three years' imprisonment. See Ill. Rev. Stat. 1989, ch. 38, par. 1005-8-2(b).
Affirmed as modified.
WELCH and CHAPMAN, JJ., concur.
