@Coopercape is almost right, but it all works so it that de Broglie's relation with $E$ dependent on $f$ and $p$ on $\lambda$ is still right. The $m$ in the equation is in fact the rest mass, so that $f\lambda$ is not $c$ for matter waves, or any waves other than those from massless particles. I'll explain a bit more below.
The relationship $E^2 = (pc)^2 + (mc^2)^2$, which is fully valid in special relativity gives the energy as the sum of a kinetic energy ($=pc$) and the rest mass energy ($mc^2$ with $m$ being the particle's rest mass). Notice that in relativity (actually both special and general) the rest mass term includes the particle's potential energy due to internal forces.
You can write the equation in terms of $f$ and wavelength $\lambda$ as
$$(hf)^2 = (hc/\lambda)^2 + (mc^2)^2$$
with $E = hf$ and $p= h/\lambda$.
This actually holds for all particles and systems, in special relativity. In general relativity you have to insert the other off-diagonal metric terms and it's a little more complex but still straightforward.
Notice that f is no longer equal to $c/\lambda$, unless the rest mass $m$ is zero. The relationship of $f$ and $\lambda$ depends on $m$, i.e., the mass of the particle. Only for $m=0$ is $f\lambda=c$. The relationship between f and $\lambda$ in general is called the dispersion relation. With $\omega = 2\pi f$, and k = $2\pi$/$\lambda$ one gets a simple relation if one sets natural units with $2\pi h$ = c = 1,
$$\omega^2 = k^2 + m^2$$
with $m$ still the rest mass. This is called the wave's dispersion relations.
It is well understood in physics.
See the Wikipedia article in the section Matter Waves. https://en.m.wikipedia.org/wiki/Energy_momentum_relation
See also about dispersion relations in general at https://en.m.wikipedia.org/wiki/Dispersion_relation