From nobody Thu Apr 2 13:48:21 2026 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 C429633B95B for ; Sat, 28 Mar 2026 19:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774726065; cv=none; b=YBcnnb8ymQzdb0wfGATcN/p2jLJfrW9++hH8j72oPtd8EGw2Lj0mIP6TPVoW9zniIoQrpGc1w2nTBz7GnhaBTCb5/cN6R3gcZ4DP/LHDQ1JzxkTTU4JILRt8HfyqBFF1LnARAV102ohW8+Nc5MItmbxmNy8OI6RRzeTzfKioISA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774726065; c=relaxed/simple; bh=bC0DKDjrQLAjjJkrfj+dG8LmOIgjlk2HJJxcYl7Mhe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCEf01XtBFmhSrXcCOQwo/Nr1SemP5OjMHWcTZ20rkHlm/qbsRrqRIdaMzggpwRaKyEU67Mv+GOkpjopNLBPTlhgHjLG8FxHI920mMnRJL/awSOo4ywoQc8wZcCfeYaLqDgb0IU8nOycMtyCn/4ejeBM30V9tUfb+CGC1tMaxy8= 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=oN/1ui3u; arc=none smtp.client-ip=209.85.208.53 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="oN/1ui3u" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-66aed966c7eso5139991a12.3 for ; Sat, 28 Mar 2026 12:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774726062; x=1775330862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2iKU/akDxfnh1nRLdbpAkE2AClT7RbbA3fVQinl+Nh0=; b=oN/1ui3ucAERExGI1uD1oNk37i51iwKXA73ro1i9wAeQoSHH1ocekC2fO89JCx2LXa dPYpUt6PnN36HMkUtxOoM4zzqEVyFsApSED0rDsYcAUH1f6c3Lcy9BPzK8YP/HhX8yjw Bs3INSgTqDS3HCun4oPsT/0LVajl+DjpUeQeVYsPDCt64oyD7eNaqF1GsrdM8aXDGBrh tkfyyDzwjtzJFfXgS3Ez4OUNSd1dRPVGuIXP1OLxzmHKNNLxMMFrhqf4XdNok/FkeSfJ m23cbf2fR8YCGXzGOWvpRBpvb2R1l8bGGjnpwKcLTJ58DsAnMGhs7JAo8AWQZjo7h4qV fhNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774726062; x=1775330862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2iKU/akDxfnh1nRLdbpAkE2AClT7RbbA3fVQinl+Nh0=; b=KLuLTd3dsoPhGnhtspQ2OydhAA1HLr7LFf6VnifEu5dB7Y+ehqb2s67ppMmvssHJyC OVege9adTW309jl+ECYn616YccX5fEPSbmJWosZ+A2jBc2ZmkreurZUn0Dfr30wbDjHx pnXs1KYSd4Fu5xfdw39bhvt4JDDR1FnguAzzlMaJUTg7XLSgFb/Fqb9e7wL6vEV/WAmr 9g5+pA38AnUPnl8VSrXbU9odAJXmZzJWImagEn1IdVOKj848t3+qqE5b2pLMBrcBbjzN fpZFIOAASSCAJK8qATDyD1KPl2zf2V3y8/4V0bbNB9B+p5T9ujotbXlah3EuXVVLaxRK PhuQ== X-Forwarded-Encrypted: i=1; AJvYcCWWU5Kh52EA6B9RXlyrO93USrQKbAv81tQJla1P5Tk2yB6Fpdoj3JNNbbwU0lYpRasClVgaE+xNIAi9f3c=@vger.kernel.org X-Gm-Message-State: AOJu0YxAmKD8bgivaI7A29YtJR7G5Y/Dnl7owb94kKqry+rN9e4lODYc d9tHccqkKTmjCuTMplsZqhGHpHcmsErwwAtKWZo+kotYQmOnB/9OClll X-Gm-Gg: ATEYQzxa17R6fQVwK8ABkQl7Sg+XCENeQPMJIYVurYFoBN4PTKchC/Il4MN1N3PdKpi 30YSer/SHW34wZGccUdjGvs51ezdelH8iAuxeAMNWWYeqVAiaA7WS6X/SK0ubE5EINU6CYSRtZM 17JJYXFUeaQhnjFShqZJ2zp71jiQgn1gKamjgdtjzIW92qoSE07PROgZcDQFRJ+QiBYtC2739s8 Q+umWBJRerg7BbmpgmV0ho//ctLSpypx8fRvCql/9fIDf/0CG9jZMM3lA8yitmM4zYQ+KBChEHF ge2wAf9LOD9z+FboLPutgGSI1b7AC6O7S5eDithBlZu5pzWVBB58Gb5IDBQPOB05yEJjeFaBtow tnonjEPG/mAPPEIcn/PqvjXXxSpX2rLDm3bBr4ETQFn7F+YNl0RmbVH6RD531jnYxvtOUzf42J0 t0nf4O7jyImM8nRwXOK9xLyMcXRCTdBHdYqs1bWuS1KtgeMw== X-Received: by 2002:a05:6402:3583:b0:66b:8f61:a928 with SMTP id 4fb4d7f45d1cf-66b8f61ab75mr1285103a12.8.1774726062148; Sat, 28 Mar 2026 12:27:42 -0700 (PDT) Received: from localhost.localdomain ([2a00:f41:18b7:e580:68f0:a6ff:fe88:bed7]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-66b76081af8sm857420a12.27.2026.03.28.12.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 12:27:41 -0700 (PDT) From: "Jose A. Perez de Azpillaga" To: linux-staging@lists.linux.dev Cc: Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Andy Shevchenko , Greg Kroah-Hartman , Alan Cox , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] media: atomisp: fix potential NULL pointer dereference in configure_isp_from_args() Date: Sat, 28 Mar 2026 20:21:37 +0100 Message-ID: <20260328192721.255493-2-azpijr@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260328192721.255493-1-azpijr@gmail.com> References: <20260328192721.255493-1-azpijr@gmail.com> 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" The function configure_isp_from_args() incorrectly dereferences args->delay_frames[0] to configure cropping without checking if the pointer is valid. However, as noted in a FIXME comment later in the same function, delay_frames can be NULL in certain pipeline configurations. Add defensive checks for both delay_frames and tnr_frames before passing them to their respective configuration functions. This ensures that optional frames are only processed if they were actually allocated, preventing a kernel NULL pointer dereference. Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2") Signed-off-by: Jose A. Perez de Azpillaga --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/stagin= g/media/atomisp/pci/sh_css_sp.c index 6da151e7a873..2904455b35f7 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -775,9 +775,17 @@ static int configure_isp_from_args(const struct sh_css= _sp_pipeline *pipeline, ret =3D ia_css_fpn_configure(binary, &binary->in_frame_info); if (ret) return ret; - ret =3D ia_css_crop_configure(binary, ia_css_frame_get_info(args->delay_f= rames[0])); - if (ret) - return ret; + + /* + * Only configure crop if delay_frames are present. Accessing + * delay_frames[0] without this check would result in a NULL deference. + */ + if (args->delay_frames[0]) { + ret =3D ia_css_crop_configure(binary, ia_css_frame_get_info(args->delay_= frames[0])); + if (ret) + return ret; + } + ret =3D ia_css_qplane_configure(pipeline, binary, &binary->in_frame_info); if (ret) return ret; @@ -808,21 +816,23 @@ static int configure_isp_from_args(const struct sh_cs= s_sp_pipeline *pipeline, return ret; =20 /* - * FIXME: args->delay_frames can be NULL here - * - * Somehow, the driver at the Intel Atom Yocto tree doesn't seem to - * suffer from the same issue. - * - * Anyway, the function below should now handle a NULL delay_frames - * without crashing, but the pipeline should likely be built without - * adding it at the first place (or there are a hidden bug somewhere) + * Safely handle pipelines built without delay_frames */ - ret =3D ia_css_ref_configure(binary, args->delay_frames, pipeline->dvs_fr= ame_delay); - if (ret) - return ret; - ret =3D ia_css_tnr_configure(binary, args->tnr_frames); - if (ret) - return ret; + if (args->delay_frames[0]) { + ret =3D ia_css_ref_configure(binary, args->delay_frames, pipeline->dvs_f= rame_delay); + if (ret) + return ret; + } + + /* + * Safely handle TNR frames as well + */ + if (args->tnr_frames[0]) { + ret =3D ia_css_tnr_configure(binary, args->tnr_frames); + if (ret) + return ret; + } + return ia_css_bayer_io_config(binary, args); } =20 --=20 2.53.0