[PATCH v2 0/3] staging: media: atomisp: use kvmalloc_objs() and drop redundant OOM messages
Rodrigo Gobbi <[email protected]> Mon, 22 Jun 2026 19:42:41 -0300
| Newsgroups | dev.linux.lists.linux-kernel-mentees,dev.linux.lists.linux-staging,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media |
|---|---|
| Message-ID | <[email protected]> |
Several allocations in the atomisp driver still size their buffers with
open-coded multiplication, e.g. width * height * sizeof(*p). When the
dimensions are large the product can silently wrap, causing kvmalloc()
to allocate an undersized buffer.
Convert the remaining sites to kvmalloc_objs() with array_size(), which
saturate to SIZE_MAX on overflow so kvmalloc() returns NULL instead of
allocating too few bytes.
This continues the work started in commit [2], and picks up the stalled
sites from [1], unifying with [3].
While here, drop the redundant IA_CSS_ERROR("out of memory") messages on
the touched allocation paths: the memory management core already emits a
far more detailed warning on allocation failure as raised at [1].
[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/torvalds/linux/commit/d178c7ca8fefc28115d35b94c3b1f4d653e34182
[3] https://lore.kernel.org/all/[email protected]/
---
Hi, all,
Regarding a comment from Andy at [3]:
> From: Andy Shevchenko <[email protected]>
> On Tue, Jun 09, 2026 at 06:46:31PM -0300, Rodrigo Gobbi wrote:
> Replace kvmalloc() with multiply with kvmalloc_objs(), which handles
> the size multiplication internally with overflow checking, silenting
> checkpatch warn.
>
> Signed-off-by: Rodrigo Gobbi <[email protected]>
> ---
> Hi, all,
> There is a ongoing effort like this for other files from atomisp
> at [1], yet, it is not covering the same file.
> Tks and regards.
>
> [1] https://lore.kernel.org/all/[email protected]/
> Yeah, the problem is that the activity seems stale. Can you pickup all
> the patches from the mailing list that have not been yet applied (regarding
> k*alloc() uses) and combine them into series or so and update regarding to
> Sakari's comments?
The only patches that I found from stale threads were added in this series,
hope that is fine now.
Tks and regards.
Changelog:
v2: convert to a series with additional stale patches;
v1: https://lore.kernel.org/all/[email protected]/
---
Rodrigo Gobbi (3):
staging: media: atomisp: use kvmalloc_objs() in make_histogram()
staging: media: atomisp: use kvmalloc_objs() for overflow-safe
allocation
staging: media: atomisp: drop redundant out-of-memory messages
.../media/atomisp/pci/sh_css_metrics.c | 11 +-
.../media/atomisp/pci/sh_css_param_dvs.c | 5 -
.../staging/media/atomisp/pci/sh_css_params.c | 101 +++++++-----------
3 files changed, 41 insertions(+), 76 deletions(-)
--
2.48.1