From nobody Tue Jun 16 04:58:59 2026 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BF4A3C455B for ; Thu, 16 Apr 2026 13:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776347188; cv=none; b=ha5vDoOIlI2+1cwa9N7VhcXePoHSfhF6Cw6+oGJ2/p+0VeLXXbjOhW77SYBfxy35GbG2kZCCv+0MNmtLsVjkiYDyYR7/rbYWodlsB9U0csFJvE/PtjRi/y58NzBvLauWeD9QWS3vNkaOQOyQPlkbdoJy1I3DhdjLn5yQXE10WIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776347188; c=relaxed/simple; bh=3EAwYE7+t5LBGy+Qw2ONJz+RCqEsQCzzTpMO2mrhpIw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KyvlQj9064BC8eUfjJ6e3AKsaRKpW4eqcmuKMfaX40A8zBwo9ezhfJ3EvO4wx8Y6DcqFf+ESM9rXuSR0ejeMSriwKYIeYm1bltQyf2nf3xurOodp8NyhnBwa6A/tUYClzD64XOTWf2o9s1qMaAeKBPsTdTXFvt7TivvKQ4zwf6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OfOl6X1I; arc=none smtp.client-ip=74.125.82.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OfOl6X1I" Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-2bdcf5970cdso526944eec.0 for ; Thu, 16 Apr 2026 06:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776347186; x=1776951986; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=So59SyK+EyB2Z67BGgN+VJWPDFL7GSSTqAp2bhFGkV4=; b=OfOl6X1IOC1hQmUh31TkatZmGWoeZn+VVMIi1Zn1Np0ViNyZyzRt5SG9R+QeEo0LKS lVkMJGZS8e9/On1HsLKucmwhTz6MDkPNrz6KWNu3nJOCDy7xXS4fAr9+HLcQHLHHFdra OguF49wvH96d0kF6/TMefw8as85RiMi82WsKsbO/r/ryw742pvsPuJ6WjesNAVFTvwYy fF0SitVGNwoykTrjeVkH+esytXR7M3tBbSCuf1CrzQY5Xp3kmZ2MO3zJgQVxzrIcYLKO 9th2iK3y/KwWg9XJloFTh4eckIltiUSEAgX5hDPL9oiHNPAzbhNahnZJElZiqjD4cYr1 C6gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776347186; x=1776951986; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=So59SyK+EyB2Z67BGgN+VJWPDFL7GSSTqAp2bhFGkV4=; b=Rm9s1IDUGuy21KZVCUEf7Xagq+ppIp0XjMPyxonxqri7MeYpmKQHYxs3bSUr+epVpZ WBZ9bKxkkLI75B6/O2z2R96JPrClBtAD6HzdZ8D/zvpddWOOgF6oz9AbjYptzdqeL1YI wFTt8BVj0YuQbJbRFqMpGWVLoHMVoIbRQb8W+0PAEbkDGdDMqx+8zqpZqvqVEIfLJJUA jKRJvIw4czWNdKkybMMQ7TG8AN77HP2L6bmba4XR0bry7AM9/xdg6Ija/EJhJm2NuQf8 SrUkBtn40F0xIXTOexICJNlHA6WjIx7iX6i+/K+7Z1spQGvPZ86H7bPxqvF9PwXscapX ItFQ== X-Forwarded-Encrypted: i=1; AFNElJ8H2+AdwNpSLrFPsqS/IgMyIJGskb5bxcBSz3DXGhc51iP0aaVAW6MWYAQ1eNAf3pupBDv8qTVsGYWo5vU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz46tfM232FtsqXG80XCQbE3Zez754dR9aKAzpNheJ2AMP8f0sa IenLzXvGOjWX0Oosj0mXDbCui5r1BOOxuMHgcXKaLCgkry/YOCZVab8L X-Gm-Gg: AeBDietOMu6hL35f9Xe1YrZR3fSmSvUM+OJ79SKBjJptXmtLyK6qao/iUm88vJ3jb1Q hxv2K4udsHLvMos4CVzJdUP/V8HihZN775d6yoB3p301wVVavZ1ii83FWK8ihDN+oRW/5zK3D7s kWl/yRMeFjG5uP9/YqDivGx+CmHbhZHy5gAvbY72JBssmvLCOoTnf38eCqnpBCXtJk0fa1DAeIU g+jh+TiFQkqsUCHqgIgtJgnXT0O7ggvEmR5lrgQFRTXfvylvrN7ymL0Cz5ovAYem3nUQPFLTBYp cW+07XNw+A+fZGWnu3G8i3PeTJ7UjPjuw8+8SnmeFrDcZA5bIBOi3udazDUP3G2xMPRm4/Hv70M o4uCwBcg1YwXodq1jtw2QDqpe5/RNQHXdVfsrlX9DOyV8ZzS90gdK3mHWxrpuFK8IGpTBOg1KhE G+dEFqK6a1/5ECPUmLwZTkPsq0m69AWVbn9+iPWA== X-Received: by 2002:a05:7300:ac81:b0:2c6:67b6:3acc with SMTP id 5a478bee46e88-2df7f4671e7mr1831946eec.15.1776347186136; Thu, 16 Apr 2026 06:46:26 -0700 (PDT) Received: from pedro-oxean-machine ([2804:214:400b:a09:b5a8:d8b1:e224:db26]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2de8f965c5fsm7256740eec.26.2026.04.16.06.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 06:46:25 -0700 (PDT) From: Pedro Pontes To: hansg@kernel.org, gregkh@linuxfoundation.org, mchehab@kernel.org Cc: andy@kernel.org, sakari.ailus@linux.intel.com, kees@kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Pedro Pontes Subject: [PATCH] media: atomisp: use kmalloc_objs for array allocations Date: Thu, 16 Apr 2026 10:42:15 -0300 Message-ID: <20260416134214.130665-2-pontescpedro@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert manual kmalloc() multiplications to the modern kmalloc_objs() interface to improve type safety and prevent potential integer overflows. Signed-off-by: Pedro Pontes --- This patch is a refresh and modernization of the following work by Qianfeng Rong from August 2025: Link: https://lore.kernel.org/all/20250821081746.528018-1-rongqianfeng@vivo= .com/ The original version used manual multiplications; I have updated it to use the newer kmalloc_objs() macro and enforced pointer-based type inference (e.g., *descr->in_info) as is now the preferred standard for these cleanups. The patch has been verified with a W=3D1 build for pci/sh_css.o. Since I don't own the hardware. Please note that, since I'm a new contributor, I wasn't quite sure in how to proceed in this scenario of "redoing" an older contribution. I've credited the original author with the "Originally-authored-by" tag. Please let me know if I should have done something differently. drivers/staging/media/atomisp/pci/sh_css.c | 57 ++++++++++++---------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/m= edia/atomisp/pci/sh_css.c index 6cda5925fa45..26b7ea560c02 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -5819,36 +5819,37 @@ static int ia_css_pipe_create_cas_scaler_desc_singl= e_output( i *=3D max_scale_factor_per_stage; } - descr->in_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->in_info =3D kmalloc_objs(*descr->in_info, + descr->num_stage, + GFP_KERNEL); if (!descr->in_info) { err =3D -ENOMEM; goto ERR; } - descr->internal_out_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->internal_out_info =3D kmalloc_objs(*descr->internal_out_info, + descr->num_stage, + GFP_KERNEL); if (!descr->internal_out_info) { err =3D -ENOMEM; goto ERR; } - descr->out_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->out_info =3D kmalloc_objs(*descr->out_info, + descr->num_stage, + GFP_KERNEL); if (!descr->out_info) { err =3D -ENOMEM; goto ERR; } - descr->vf_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->vf_info =3D kmalloc_objs(*descr->vf_info, + descr->num_stage, + GFP_KERNEL); if (!descr->vf_info) { err =3D -ENOMEM; goto ERR; } - descr->is_output_stage =3D kmalloc(descr->num_stage * sizeof(bool), - GFP_KERNEL); + descr->is_output_stage =3D kmalloc_objs(*descr->is_output_stage, + descr->num_stage, + GFP_KERNEL); if (!descr->is_output_stage) { err =3D -ENOMEM; goto ERR; @@ -5968,35 +5969,37 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pi= pe *pipe, descr->num_stage =3D num_stages; - descr->in_info =3D kmalloc_objs(struct ia_css_frame_info, - descr->num_stage); + descr->in_info =3D kmalloc_objs(*descr->in_info, + descr->num_stage, + GFP_KERNEL); if (!descr->in_info) { err =3D -ENOMEM; goto ERR; } - descr->internal_out_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->internal_out_info =3D kmalloc_objs(*descr->internal_out_info, + descr->num_stage, + GFP_KERNEL); if (!descr->internal_out_info) { err =3D -ENOMEM; goto ERR; } - descr->out_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->out_info =3D kmalloc_objs(*descr->out_info, + descr->num_stage, + GFP_KERNEL); if (!descr->out_info) { err =3D -ENOMEM; goto ERR; } - descr->vf_info =3D kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + descr->vf_info =3D kmalloc_objs(*descr->vf_info, + descr->num_stage, + GFP_KERNEL); if (!descr->vf_info) { err =3D -ENOMEM; goto ERR; } - descr->is_output_stage =3D kmalloc(descr->num_stage * sizeof(bool), - GFP_KERNEL); + descr->is_output_stage =3D kmalloc_objs(*descr->is_output_stage, + descr->num_stage, + GFP_KERNEL); if (!descr->is_output_stage) { err =3D -ENOMEM; goto ERR; -- 2.53.0