If anything, farming made societies more susceptible to famine. Specialization of labor and dependence on a specific plot of land made it much harder to simply move somewhere else when food was scarce. Hunter-gatherers and herders were almost always nomadic and moved to wherever food was available.