Re: [PATCH] fbdev: arkfb: Move a variable assignment behind a condition check in ics5342_init()

Helge Deller <[email protected]> Sat, 18 Jul 2026 20:17:16 +0200
Newsgroups org.kernel.vger.kernel-janitors,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-fbdev,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/13/26 12:18, Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Mon, 13 Jul 2026 12:12:52 +0200
>=20
> The address of a data structure member was determined before
> a corresponding null pointer check in the implementation of
> the function =E2=80=9Cics5342_init=E2=80=9D.
>=20
> Thus avoid the risk for undefined behaviour by moving the assignment
> for the variable =E2=80=9Cinfo=E2=80=9D behind a condition check.
>=20
> This issue was detected by using the Coccinelle software.

There is no "risk" here.
It just adds an offset to a potential NULL value (which isn't then used af=
terwards).

Helge=20
> Fixes: ede481f6dad47d40b7e561cfbc6c04286a9faf1a ("fbdev: arkfb: Cast ics=
5342_init() allocation type")
> Cc: [email protected]
> Signed-off-by: Markus Elfring <[email protected]>
> ---
>   drivers/video/fbdev/arkfb.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>=20
> diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
> index 195dbf4a5142..9658f407b79a 100644
> --- a/drivers/video/fbdev/arkfb.c
> +++ b/drivers/video/fbdev/arkfb.c
> @@ -432,11 +432,12 @@ static struct dac_ops ics5342_ops =3D {
>   static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_r=
egs_t dwr, void *data)
>   {
>   	struct ics5342_info *ics_info =3D kzalloc_obj(struct ics5342_info);
> -	struct dac_info *info =3D &ics_info->dac;
> +	struct dac_info *info;
>  =20
>   	if (!ics_info)
>   		return NULL;
>  =20
> +	info =3D &ics_info->dac;
>   	info->dacops =3D &ics5342_ops;
>   	info->dac_read_regs =3D drr;
>   	info->dac_write_regs =3D dwr;