clEnqueueReadBuffer not writing to buffer

I am new to OpenCL and I am trying to make a parallel renderer of the Mandelbrot set. It worked yesterday and I'm pretty sure I didn't modify anything in my code but the clEnqueueReadBuffer command seems to not be doing anything there. Anything to improve my code is also welcome.

int draw_image(t_plan *plan, t_ocl_data *ocl_data)
{
    cl_mem  img_mem;
    size_t  global_size[2];
    size_t  local_size[2];
    cl_int  err;

    img_mem = image_to_cl_buffer(&plan->image, ocl_data->context);
    fill_image(plan->image, 0x6f42f5);
    err = clSetKernelArg(ocl_data->kernel, 0, sizeof(cl_mem), &img_mem);
    global_size[0] = plan->image.res.x;
    global_size[1] = plan->image.res.y;
    local_size[0] = plan->image.bpp;
    local_size[1] = plan->image.bpp;
    err = clEnqueueNDRangeKernel(ocl_data->cqueue, ocl_data->kernel, 2, NULL, global_size, NULL, 0, NULL, NULL);
    if (err != CL_SUCCESS)
    {
        printf("%d\n", err);
        exit(0);
    }
    sleep(1);
    err = clEnqueueReadBuffer(ocl_data->cqueue, img_mem, CL_TRUE, 0, plan->image.total_size, plan->image.img_data, 0, NULL, NULL);
    if (err != CL_SUCCESS)
    {
        printf("%d\n", err);
        exit(0);
    }
    return (0);
}
double lerp(int x, int xmax, double low, double high);

double lerp(int x, int xmax, double low, double high)
{
    return (x * (high - low) / xmax + low);
}

__kernel
void mandelbrot(__global int *img_data)
{
    int x = get_global_id(0);
    int y = get_global_id(1);
    int width = get_global_size(0);
    int height = get_global_size(1);
    int max_iter = 256;
    int i = 0;
    double a = lerp(x, width, -2.5, 1.0);
    double b = lerp(y, height, -1.0, 1.0);
    double na = 0;
    double nb = 0;
    double n_a = 0;
    double n_b = 0;
    while (n_a + n_b <= 4 && ++i < max_iter)
    {
        nb = 2 * nb * na + b;
        na = n_a - n_b + a;
        n_a = na * na;
        n_b = nb * nb;
    }
    img_data[y * width + x] = i | i << 8 | i << 16;
}