From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25AF82D6E44 for ; Mon, 15 Jun 2026 19:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781552783; cv=none; b=joamkw2yGQYEqR6tZKXZrvntkvwV6AAGZ7BEhHjpNQwJuV9uW/v4+BWI0Kf9cToefEHK9XezijRe4d/QrfJC4QtFYiNhcu9gc50SUlCjcQ0EG4AhYY5kupy4eu8mfw0Um0FTL4YR+8Au3Kl6VpOI5b4DVVDGmXbrQCowbTRTSho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781552783; c=relaxed/simple; bh=F8//HOzop0wZqkW/+yb7DeIyN49eYkCf+tfjSwgBSAc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FEHnMNspRL2oA3m0WRnfa3+of56mLQWiXsTFtYkZU/m7RnrCWuuvgjxKQjFuOaE1WtVlAG/v0bRPgUo0sqcSDKy0PT6NvGkyvI328L6gzuJ0zDA34O0DQDAwwZBe4EwDyvyTcLzyHzixcRqKqCfS7DtWbOP4tkfA8L55T+NkuWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b=f7eV5/hQ; arc=none smtp.client-ip=80.241.56.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="f7eV5/hQ" Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4gfLGJ0P1vz9twp; Mon, 15 Jun 2026 21:46:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1781552776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=jjACC5qVmQdhDivw9+MwXW4hAT6BcvtyY3lMI/q4T9k=; b=f7eV5/hQ5M2hXepRuXTZ9xMoVhA4zkfddYd/mdhL7BI+Azz91j4tzJKahxlk1dT8iZ0eg8 sbK8edTrSRUoxzPr1ra9QU7mvzvzJcEvTgWRka13ACYlJEuLeJRNz8dA7AKDUznkOBYmFc SW6q+G4hGC8bLaCxNULfa1LSPdE23INP8eAZeUVXgKSE2qld+f8rMHs6GEm+qoTgSae4OB 5R9D8ytn/yt9e0+rGMWkh/EtIwm4U/YrOxPaNOcnB5Os7I9eUq1Z9FZfpZaboeL2dXLPzk Jn8I1CHieVTHqx3OErrWivQ9ckdqvsbUPehuwsoCDq3nH4FMXLaAOIEhhBaucA== From: Andrei Khomenkov To: Greg Kroah-Hartman , Andy Shevchenko Cc: linux-staging@lists.linux.dev, linux-media@vger.kernel.org Subject: [PATCH v3] media: atomisp: replace kmalloc() with kmalloc_objs() in sh_css.c Date: Mon, 15 Jun 2026 22:45:48 +0300 Message-ID: <20260615194548.20963-1-khomenkov@mailbox.org> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MBO-RS-ID: 14346f74dab98064f4f X-MBO-RS-META: io5uppiifitymjmgcjt1eqyqiib9iih3 Replace arithmetic in the kmalloc() function with the kmalloc_objs() macro, as this calculation method is unsafe. Suggested-by: Andy Shevchenko Signed-off-by: Andrei Khomenkov --- v3: - use 'kmalloc_objs()' macro instead of 'kmalloc_array()' function - drop unused 'GFP_KERNEL' arguments since they are default v2: - use 'sizeof(*ptr)' instead of explicit type v2: https://lore.kernel.org/linux-staging/20260613110712.71436-1-khomenkov@mailbox.org/ v1: https://lore.kernel.org/linux-staging/20260606095410.13968-1-khomenkov@mailbox.org/ drivers/staging/media/atomisp/pci/sh_css.c | 34 ++++++---------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 6cda5925fa45..0733d33101b2 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -5819,36 +5819,27 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output( i *= max_scale_factor_per_stage; } - descr->in_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->in_info, descr->num_stage); if (!descr->in_info) { err = -ENOMEM; goto ERR; } - descr->internal_out_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->internal_out_info, descr->num_stage); if (!descr->internal_out_info) { err = -ENOMEM; goto ERR; } - descr->out_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->out_info, descr->num_stage); if (!descr->out_info) { err = -ENOMEM; goto ERR; } - descr->vf_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->vf_info, descr->num_stage); if (!descr->vf_info) { err = -ENOMEM; goto ERR; } - descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool), - GFP_KERNEL); + kmalloc_objs(descr->is_output_stage, descr->num_stage); if (!descr->is_output_stage) { err = -ENOMEM; goto ERR; @@ -5974,29 +5965,22 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe, err = -ENOMEM; goto ERR; } - descr->internal_out_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->internal_out_info, descr->num_stage); if (!descr->internal_out_info) { err = -ENOMEM; goto ERR; } - descr->out_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->out_info, descr->num_stage); if (!descr->out_info) { err = -ENOMEM; goto ERR; } - descr->vf_info = kmalloc(descr->num_stage * - sizeof(struct ia_css_frame_info), - GFP_KERNEL); + kmalloc_objs(descr->vf_info, descr->num_stage); if (!descr->vf_info) { err = -ENOMEM; goto ERR; } - descr->is_output_stage = kmalloc(descr->num_stage * sizeof(bool), - GFP_KERNEL); + kmalloc_objs(descr->is_output_stage, descr->num_stage); if (!descr->is_output_stage) { err = -ENOMEM; goto ERR;