Re: [PATCH v2 2/3] staging: media: atomisp: use kvmalloc_objs() for overflow-safe allocation
Andy Shevchenko <[email protected]> Tue, 23 Jun 2026 13:22:57 +0300
| Newsgroups | dev.linux.lists.linux-kernel-mentees,dev.linux.lists.linux-staging,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
On Mon, Jun 22, 2026 at 07:42:43PM -0300, Rodrigo Gobbi wrote: > Several allocations in sh_css_params.c still size their buffers with > open-coded multiplication (e.g. width * height * sizeof(*p)), which can > silently overflow and under-allocate. > > Convert them to kvmalloc_objs() with array_size(), which saturate to > SIZE_MAX on overflow so kvmalloc() returns NULL instead of allocating > too few bytes. ... > + me->hor_coefs = kvmalloc_objs(*me->hor_coefs, > + array_size(grid->num_hor_coefs, > + IA_CSS_DVS_NUM_COEF_TYPES)); Here and elsewhere with long line, do like you have done in one case with a temporary variable cnt. It makes same number of lines of code, but readability is better. > if (!me->hor_coefs) > goto err; -- With Best Regards, Andy Shevchenko