Re: [PATCH v2 11/28] binder: do unlocked work in binder_alloc_new_buf()

From: Alice Ryhl
Date: Mon Dec 04 2023 - 06:57:22 EST


> Extract non-critical sections from binder_alloc_new_buf_locked() that
> don't require holding the alloc->mutex. While we are here, consolidate
> the checks for size overflow and zero-sized padding into a separate
> sanitized_size() helper function.
>
> Also add a few touchups to follow the coding guidelines.
>
> Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

> + if (IS_ERR(buffer)) {
> + mutex_unlock(&alloc->mutex);
> + goto out;
> + }
> +
> + buffer->data_size = data_size;
> + buffer->offsets_size = offsets_size;
> + buffer->extra_buffers_size = extra_buffers_size;
> mutex_unlock(&alloc->mutex);
> +
> +out:
> return buffer;
> }

You could also write this as:

if (!IS_ERR(buffer)) {
buffer->data_size = data_size;
buffer->offsets_size = offsets_size;
buffer->extra_buffers_size = extra_buffers_size;
}

mutex_unlock(&alloc->mutex);
return buffer;

But I'm happy either way.

Alice