you need to give out more information as to what troubleshooting step you did to verify your Ryzen is defective and your PC Information including Make & Model and Software versions installed.
If your Ryzen is less than 3 years old and you have a valid Retail Receipt showing you as the original owner and date of purchase and the Ryzen came in a Official AMD Retail Box then I suggest you first open a AMD SUPPORT-WARRANTY Ticket to see if you need to RMA your processor or not.
They will give you the link to return your processor under Warranty.