kernel: preserve the sm state when handling IS_ERR()