
965 N.E.2d 529 (2012)
358 Ill. Dec. 458
The PEOPLE of the State of Illinois, Plaintiff-Appellee,
v.
Ralphfield HUDSON, Defendant-Appellant.
No. 2-10-0484.
Appellate Court of Illinois, Second District.
January 27, 2012.
Rehearing Denied March 5, 2012.
*530 Thomas A. Lilien, Deputy Defender, Kim M. DeWitt, Office of the State Appellate Defender, Elgin, for Ralphfield Hudson.
Joseph P. Bruscato, State's Attorney, Rockford (Lawrence M. Bauer, Deputy Director, Kristin M. Schwind, State's Attorneys Appellate Prosecutor, Elgin, of counsel), for the People.

OPINION
Justice BIRKETT delivered the judgment of the court, with opinion.
¶ 1 Defendant, Ralphfield Hudson, appeals from the dismissal of a document that the court characterized as a petition under the Post-Conviction Hearing Act (Act) (725 ILCS 5/122-1 et seq. (West 2006)). He asserts that, under the rule in People v. Gregory, 379 Ill.App.3d 414, 318 Ill.Dec. 531, 883 N.E.2d 762 (2008), his 1996 conviction of aggravated driving under the influence of cocaine (625 ILCS 5/11-501(a)(5), (d)(1)(C) (West 1994)) was void. He argues that, per Gregory, the conviction was void because it was the result of a plea agreement that required a void sentence, one longer than the law allowed. We do not accept the rule in Gregory, which is inconsistent with People v. Brown, 225 Ill.2d 188, 310 Ill.Dec. 561, 866 N.E.2d 1163 (2007), and which, as applied here, would give defendant an unbargained-for benefit. The proper remedy for an illegally long sentence is to correct the sentence. In this case, we make the correction of reducing the sentence from five years' imprisonment to three. That the correction comes too late to aid defendant (who has served out his five-year sentence) does not make any other remedy necessary.

¶ 2 I. BACKGROUND
¶ 3 A grand jury indicted defendant on one count of possession of less than 15 grams of cocaine (720 ILCS 570/401(c)(2) (West 1994)), one count of possession of less than 15 grams of heroin (720 ILCS 570/401(c)(1) (West 1994)), aggravated driving under the influence of cocaine (aggravated DUI) (625 ILCS 5/11-501(a)(5), (d)(1)(C) (West 1994)), and failure to obey a traffic control device (625 ILCS 5/11-305(a) (West 1994)). The charges stemmed from a March 7, 1995, incident in which defendant's vehicle hit a bus, and the bus crashed into a restaurant, killing one person inside. In the plea agreement, the State agreed to dismiss all the charges but the aggravated DUI. The court told defendant that the sentencing range for that specific offense was 1 to 12 years' imprisonment (see 625 ILCS 5/11-501(d)(2) (West 1994)). Per the agreement, the court imposed a five-year sentence for that offense "concurrent with any federal time that he still may owe on a parole violation."[1]
¶ 4 Twelve years later, defendant filed a document that was not specifically labeled a petition under the Act. It identified defendant *531 as a prisoner in federal custody. The court treated the petition as one under the Act and summarily dismissed it, ruling that defendant, because he was not in State custody, lacked standing to file it.
¶ 5 Defendant appealed. He argued that the court should have given him the admonishments described in People v. Shellstrom, 216 Ill.2d 45, 57, 295 Ill.Dec. 657, 833 N.E.2d 863 (2005), and that, had he received such admonishments, he could have amended his petition to state a voidness claim under section 2-1401 of the Code of Civil Procedure (735 ILCS 5/2-1401 (West 2008)).
¶ 6 The State confessed error on three points. First, it agreed that defendant was entitled to the Shellstrom admonishments. Second, it agreed that, under People v. Cervantes, 189 Ill.2d 80, 243 Ill.Dec. 233, 723 N.E.2d 265 (1999), Public Act 88-680 (eff. Jan. 1, 1995) violated the single subject rule of the Illinois Constitution of 1970 (Ill. Const.1970, art. IV, § 8(d)). Public Act 88-680 created the special 1-to-12-year sentencing range in section 11-501(d)(2) of the Illinois Vehicle Code (625 ILCS 5/11-501(d)(2) (West 1994)). The prior version of the aggravated DUI provision simply made aggravated DUI a Class 4 felony (625 ILCS 5/11-501(d) (West 1992)), such that the standard Class 4 sentencing range of one to three years' imprisonment was applicable (730 ILCS 5/5-8-1(a)(7) (West 1992)). Third, it agreed that a collateral attack on a void judgment is not subject to section 2-1401's diligence requirements or two-year limitations period. This court vacated the dismissal and remanded the matter for the Shellstrom admonishments. People v. Hudson, No. 2-08-0478 (2009) (unpublished order under Supreme Court Rule 23).
¶ 7 Defendant filed amendments to his petition. The court then sent him Shellstrom admonishments. In response, defendant filed what he titled an "Amended Petition." He asserted that trial counsel had been ineffective. In a separate section, he invoked section 2-1401 and asserted that his conviction was void based on the holding in Cervantes.
¶ 8 At a hearing, the court expressed uncertainty as to what claims of defendant's were before it. The State noted the existence of the "Amended Petition" but suggested that the section 2-1401 claim did not comport with what defendant had been told in the Shellstrom admonishments. The court continued the matter. However, three days later, it entered a written dismissal order. It said that defendant's claims concerned an involuntary guilty plea and ineffective assistance of counselin other words, it did not mention the voidness claim. It said that it was dismissing the "Amended Petition" for lack of standing.

¶ 9 II. ANALYSIS
¶ 10 Initially, we note that, although the court never addressed defendant's voidness claim, its dismissal was of the entire amended petition without qualification. Therefore, we take it that the dismissal applied to the portion of the petition that defendant designated as being under section 2-1401; the dismissal was thus final as to all of defendant's claims.
¶ 11 Defendant's argument on appeal has two parts: first, that the court should have addressed his voidness claim, and second, that his conviction was void. We need address only the second part of his argument. Under People v. Thompson, 209 Ill.2d 19, 27, 282 Ill.Dec. 183, 805 N.E.2d 1200 (2004), a voidness claim can be raised for the first time on appeal, including a collateral appeal. Whether the *532 trial court acted properly has no effect on the relief available to defendant.[2]
¶ 12 We therefore turn to the merits of defendant's claim. The State again concedes that the portion of defendant's sentence beyond the statutory maximum of three years was void. We accept that concession. Defendant, relying on Gregory, asserts that it follows from the voidness of his sentence that his plea agreement was void and that his conviction was therefore void as well. We do not agree.
¶ 13 In Gregory, the court began its analysis by recognizing the existence of a significant body of case law, much of it stemming from People v. Hare, 315 Ill.App.3d 606, 248 Ill.Dec. 587, 734 N.E.2d 515 (2000), concerning the enforceability of a plea agreement that requires an illegal sentence. Looking to such cases, the Gregory court concluded that such a plea agreement is unenforceable, provided that the unauthorized sentence is an essential term of the agreement. Gregory, 379 Ill. App.3d at 419, 318 Ill.Dec. 531, 883 N.E.2d 762 (citing People v. McNett, 361 Ill. App.3d 444, 448, 297 Ill.Dec. 378, 837 N.E.2d 461 (2005)).
¶ 14 The Gregory court took the further step of concluding that an unenforceable plea agreement results in a void conviction:
"Since defendant's burglary conviction was based on a void plea agreement, the burglary conviction is also void. A judgment is void when the trial court enters an order beyond its inherent power. [Citation.] A trial court does not have the authority to accept and enter a judgment on a plea agreement that contained a sentencing provision that was not provided by statute." Gregory, 379 Ill.App.3d at 422, 318 Ill.Dec. 531, 883 N.E.2d 762.
For the last proposition, the Gregory court relied on People v. Caban, 318 Ill.App.3d 1082, 1088, 252 Ill.Dec. 732, 743 N.E.2d 600 (2001), a case that the Gregory court recognized as stating the rule that a trial court lacks authority to impose a punishment not authorized by statute.
¶ 15 It is that last step that is our concern here. A plea agreement can be unenforceable, but it does not follow from that unenforceability that the court lacked authority to enter the conviction; that is, it does not follow that the conviction was void.
¶ 16 The result in Gregory is not consistent with supreme court precedent. In People v. Brown, 225 Ill.2d 188, 205, 310 Ill.Dec. 561, 866 N.E.2d 1163 (2007), the court held that "while a sentence, or portion thereof, not authorized by a statute is void [citation], it is void only to the extent that it exceeds what the law permits. The legally authorized portion of the sentence remains valid." (Emphasis added.) In such circumstances, the result is a windfall to the defendant because he receives a sentence lower than the one that he had bargained for. Once the sentence is corrected, no wrongs to defendant remain to be corrected, and, contra Gregory, the conviction can stand.
¶ 17 There are, however, circumstances where an illegal sentence can be fixed only *533 by allowing a defendant to withdraw his plea. For example, when a court accepts a plea agreement that provides that a defendant will receive a sentence less severe than is legally possible, due process considerations may leave no option but to allow the defendant to withdraw his plea. See People v. White, 2011 IL 109616, 352 Ill.Dec. 159, 953 N.E.2d 398 (2011).
¶ 18 In White, the defendant pled guilty to first-degree murder and possession of contraband in a penal institution in exchange for consecutive prison sentences of 28 and 4 years, respectively. The factual basis of the plea, however, established that a firearm was used in the commission of the murder offense. White, 2011 IL 109616, ¶ 6. The supreme court found that the 15-year mandatory sentencing enhancement for committing first-degree murder while armed with a firearm applied, despite the trial court's belief that it did not. White, 2011 IL 109616, ¶ 19. The White court held that a court cannot impose a sentence inconsistent with the law, even where the parties and the court agree to that sentence. White, 2011 IL 109616, ¶ 23. Therefore, since the defendant did not receive the mandatory enhancement, his sentence was below the legally required amount. Accordingly, the supreme court held that the guilty plea was void and remanded the case to the trial court with directions to allow the defendant to withdraw his plea. See White, 2011 IL 109616, ¶ 31.
¶ 19 Our supreme court has held that due process entitles a defendant to the benefit of his bargain in a plea agreement. Two possible remedies when a defendant does not receive the benefit of the bargain are: (1) either the promise must be fulfilled; or (2) the defendant must be given the opportunity to withdraw his plea. People v. Whitfield, 217 Ill.2d 177, 202, 298 Ill.Dec. 545, 840 N.E.2d 658 (2005) (citing Santobello v. New York, 404 U.S. 257, 262-63, 92 S.Ct. 495, 30 L.Ed.2d 427 (1971)). Here, the reduction of defendant's sentence gives him a better bargain than the one he entered into; therefore, he has no basis for complaint.
¶ 20 We recognize that part of defendant's sentence was void and correct it to three years' imprisonment. Therefore, no problems remain that must be corrected by vacatur of his conviction. The sentence is lawful, and defendant has received the full benefit of his bargain. We need do no more.

¶ 21 III. CONCLUSION
¶ 22 For the reasons stated, we order defendant's sentence corrected to reflect what is permitted by law, namely three years' imprisonment. As no other actions need be taken, we otherwise affirm the dismissal of defendant's petition.
¶ 23 Affirmed as modified.
Justices BOWMAN and ZENOFF concurred in the judgment and opinion.
NOTES
[1]  For the sake of simplicity, we will refer to sentencing terms without mentioning the associated terms of mandatory supervised release since those terms are not at issue in this appeal.
[2]  Both parties' arguments turn on supposed distinctions between postconviction petitions and section 2-1401 petitions as vehicles for voidness claims. However, in People v. Helgesen, 347 Ill.App.3d 672, 676, 283 Ill.Dec. 113, 807 N.E.2d 718 (2004), we held that, "as a vehicle for bringing a voidness claim in a criminal case, the Act is a fully equal alternative to section 2-1401." (Procedural differences may exist, for instance, in the availability of court-appointed counsel.) Furthermore, as Thompson makes clear, a court should address voidness claims whenever it has jurisdiction of the case.
