The largest risk is that you'll miss your connection. In this case you'll be considered a "no show" and lose your ticket. If it happens on the outbound flight, your return ticket will also be canceled.
This can be entirely out of your control, for example the first flight may be delayed. Still, you'll get no compensation from the company that ran late (possibly a small compensation for the delay, certainly not for the consequences).
In your case, the return flight is at very high risk. A slight delay, and these happen all the time, and you miss the connection.
In many cases there's no way to make one booking, or it will be a different price.
You can try kiwi.com - if you book with them they insure you against this problem. I don't know how useful is this coverage, and there's no guarantee they'll offer the price you want.
Another option is to spend a day at your intermediate destination. Have a short vacation in Madrid, and you'll surely catch your flight in spite of almost almost all delays.