Ordinarily, where separate bills of indictment are returned and the bills are consolidated for trial, as authorized by G.S. 15-152, the counts contained in the respective bills will be treated as though they were separate counts in one bill, and where there are several counts and each count is for a distinct offense, a general verdict of guilty will authorize the imposition of a judgment on each count. S. v. Braxton, 230 N.C. 312, 52 S.E. 2d 895; S. v. Harvell, 199 N.C. 599, 155 S.E. 257; S. v. Mills, 181 N.C. 530, 106 S.E. 677.
Likewise, where there are several counts in a bill, and a general verdict of guilty is returned, “if the verdict on any count be free from valid objection and having evidence tending to support it, the conviction and sentence for that offense will be upheld.” S. v. Murphy, 225 N.C. 115, 33 S.E. 2d 588; S. v. Graham, 224 N.C. 347, 30 S.E. 2d 151. Where cases are consolidated for trial and there is a conviction or plea of guilty on several counts, the court may enter a judgment on each count and have the judgments run concurrently or consecutively as it may direct. But the court is not authorized by law to enter a judgment in gross in excess of the greatest statutory penalty applicable to any of the counts upon which there has been a conviction or plea of guilty. S. v. Murphy, supra; *550 S. v. Cody, 224 N.C. 470, 31 S.E. 2d 445. The State concedes this to be true, but insists that this case should be remanded for proper judgment upon the separate counts.
It is true the trial court might have imposed a sentence of two years for each of the four offenses to which the defendant entered a plea of guilty and directed that such sentences run consecutively, but this was not done. Hence, the sentence imposed for not less than six nor more than seven years is clearly excessive since the maximum term for which the defendant could have been legally sentenced upon any of his pleas was two' years.
There appears to be considerable conflict in the authorities on the question as to whether a judgment imposing an excessive sentence is wholly void or void only as to the excess. The greater weight of authority, however, is to the effect that where a court of general jurisdiction has jurisdiction of the person and the offense, the imposition of a sentence in excess of what the law permits does not render the legal and authorized portion of the sentence void, but leaves open to attack only such portion of the sentence as is excessive. Therefore, the person in custody under such sentence may not be discharged on habeas corpus until he has served so much of it as it was within the power of the court to impose. S. v. Hooker, 183 N.C. 763, 111 S.E. 351; 15 Am. Jur., Criminal Law, section 460, page 118, and cited cases. See also United States v. Peeke, 153 F. 166; Wilson v. Bell, 137 F. 2d 716; Kitt v. United States, 138 F. 2d 842; National Discount Corp. v. O’Mell, 194 F. 2d 452; In re Bonner, 151 U.S. 242, 38 L. Ed. 149; Abeyta v. People, 112 Colo. 49, 145 P. 2d 884; Manning v. Commonwealth, 281 Ky. 453, 136 S.W. 2d 28; Adams v. Russell, 179 Tenn. 428, 167 S.W. 2d 5; Royster v. Smith, 195 Va. 228, 77 S.E. 2d 855. For additional cases supporting the above view, see Annotation: 76 A.L.R. 476 where citations from thirty-nine jurisdictions are cited, including S. v. Hooker, supra.
It is the general rule in this jurisdiction that where a defendant has been properly convicted but given a sentence in excess of that authorized by law, and comes to this Court pursuant to a petition for writ of cer-tiorari in a habeas corpus proceeding, when such defendant has not served as long under the sentence as he might have been legally imprisoned, we vacate the improper judgment and remand for proper sentence. In such case, the defendant should be given credit for the time served under the vacated judgment. S. v. Templeton, 237 N.C. 440, 75 S.E. 2d 243; S. v. Miller, 237 N.C. 427, 75 S.E. 2d 242; In re Ferguson, 235 N.C. 121, 68 S.E. 2d 792; In re Sellers, 234 N.C. 648, 68 S.E. 2d 308; S. v. Silvers, 230 N.C. 300, 52 S.E. 2d 877. But, where the defendant has served for a longer period than he might have been legally sentenced on any count or plea in the court below, he is entitled to his discharge on a writ of habeas *551 corpus. In re Holley, 154 N.C. 163, 69 S.E. 872; United States v. Pridgeon, 153 U.S. 48, 38 L. Ed. 631; In re Sivan, 150 U.S. 637, 37 L. Ed. 1207; In re Howard, 69 Cal. App. 164, 158 P. 2d 408; United States v. Peeke, supra.
In tbe last cited case, the Court had before it the precise question we have here. The defendant had been convicted on five counts and might have been sentenced to two years on each count, but instead he was given a sentence of five years. The Court said: “The prisoner has already served two years, and it may be asked upon which count of the indictment did he serve this term . . . ? ... It is undoubtedly a single judgment for a single term of five years, and, the maximum time for which the defendant can be imprisoned for any offense of which he was convicted in the five different counts being two years, the sentence is good to that extent (Goode v. United States, 159 U.S. 663, 16 Sup. Ct. 136, 40 L. Ed. 297), and as to that part of the sentence in excess of the power of the court to impose it is void (In re Bonner, 151 U.S. 242, 14 Sup. Ct. 323, 38 L. Ed. 149), and it may be dealt with in this proceeding without disturbing the valid portion of the sentence. United States v. Pridgeon, 153 U.S. 62, 14 Sup. Ct. 746, 38 L. Ed. 631.” The Court thereupon affirmed the order of the District Court, directing the discharge of the petitioner from custody.
The defendant having served more than three years under the sentence imposed, and all beyond two years of the sentence being excessive, he is entitled to he discharged and it is so ordered. Therefore, let this opinion he certified immediately to the Superior Court of Richmond County to the end that the petitioner may be released from custody as directed herein.