Excess Roth IRA Contribution

I made a Roth IRA contribution in 2022 for tax year 2021 before realizing my MAGI was over the limit. 

Upon realizing this mistake, I withdrew the contribution and earnings before filing my taxes. My understanding is as follows:

1. Because I withdrew the contribution and earnings before filing my taxes, I avoid the 6% excise tax on excess contributions.

2. I will need to pay taxes on the earnings in 2023 for tax year 2022. These earnings are subject to the 10% early withdrawal penalty because I'm under the age of 59 1/2 and there is no way around avoiding this penalty.

 

Is this correct?