Based on the information you have provided, I would say that is correct.
IRS form 5329 is the correct form to use. Look at part II, where it says "Complete this part if you included an amount in income, on Form 1040 or Form 1040NR, line 21, from a Coverdell education savings account (ESA), a qualified tuition program (QTP), or an ABLE account." A qualified tuition program (QTP) is a 529 plan. On part II line 5, you would enter the amount of the earnings portion of the non-qualified distribution, which is reported on your form 1040 (line 21). If you are allowed an exception to the 10% additional tax, on part II line 6 you again enter the earnings portion of the non-qualified distribution, resulting in a $0 on line 7, which is the amount to apply the 10% additional tax to.