From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796564103; b=b+0rlfHDF8efEcIYzWPtfGXcO1xvKBqpI/tQy2ispRIpnUm1z1Ldx6KFPlOxL8pJvtmK SaTyKgWuwRCNFGvCewvoAbfdS+TCSMetQ+bV6FvgdF8W4WleSKBaZWYV3zeHfwyFRwTfm SPFWMCcC0wL/VQMxmfbvvAKYomKBH7WcrtweAzdI7oX4dyR4SBvVa6f3maYpQ17I6qmeO x451B2Dm9QPE+bu6VTn5E5MtbaPbcgKta4MF5ZVI7ICWo92TefrnlKX1r11o4iSJEpigr wRG31NPnP716MvnklkwDCzT5mUQfSgS4joX+I8bixHbcGITRVzeGDFfnXShy9H3m6Zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796564103; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kYOqTY495BDFRl46A5aZtohIjuYBjzZfs9CrPFc+r4s=; b=W3bYRwI2Ds+vSk9NPSItKqSVOS8vdBQL62r/HE4cuBnGV/Z/+nhqOzDCKmdNl3uqJmCk ++XQgNkEfqE0nmQgSJZ6zDY3f0Tvnhtd5VybGnPbNsQkhUFX60UV5zfPcEopw5fdAfeRx 7WR6rVTO3NMUPnnMmzftcENm59aCndpGQVs7Cc4m67hEhXfgzw64YFTxdWeNqeZxFaOQq 1f7IJ7Lsf+R7CGi7jqZdfNsSOWMG5NRdNoLz4/N/fu+XM1rfALrSC++MvQyeoPiXkbXfB f6zu4sgT9mzP6sWQKdEZ3/s1Z3UyzB/588X1PxV6PBLSvr7wN9ZA8Kuu+AlstvWLacw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KVgJvvLG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C6DC606A31F for ; Sun, 6 Dec 2026 13:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KVgJvvLG Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC9E1F0093B; Sun, 6 Dec 2026 13:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796564103; bh=kYOqTY495BDFRl46A5aZtohIjuYBjzZfs9CrPFc+r4s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=KVgJvvLGRZyUoqH4ILLaHFdiB/qIT6vz5x/ZtW60pieJzsLeG6qLfDtDpos9PElB8 EkuLfxxBtlURQ9uFlmnUzPlWqOw5wmn+FYm7NeOllIMfDLaOdpP5+ZgSNZQ/Pqmzga 51L63DIBGLVuALIQ9OdaWxTS7SbH9vjJp9pmg0jpibU8WhDmtAb/WXllb6D41LYq43 pdOp0RFDNSCtL2CUD+dOVDsc4UWclrlOxS7P1Lrgqo6zfdXr2+gclAJu7MK1b39LhA fE69k6/AJ444sPGMF9N5EPcqQsM45Rtj89kN/YiNMVCCjw0PByvRTjUANJPzgYhmDh vRNAe26nnpOiQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v1 2/2] drm/sitronix: Add driver for Sitronix ST75256 LCD panels Reply-To: sashiko-reviews@lists.linux.dev To: "Cyril Hrubis" , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Cc: robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261206131330.1754178-3-chrubis@suse.cz> References: <20261206131330.1754178-1-chrubis@suse.cz> <20261206131330.1754178-3-chrubis@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 13:35:02 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Critical] drm/sitronix: heap overflow in st75256_fb_blit() on fractional src coords - [High] drm/sitronix: double offset OOB read and raw vmap memcpy in st75256_fb_blit() - [Medium] drm/sitronix: unsafe memcpy() on vmap->vaddr in st75256_fb_blit() - [Medium] drm/sitronix: partial damage clips after CRTC enable leave screen blank - [Medium] drm/sitronix: inconsistent hardware state after st75256_hw_init() failure - [Medium] drm/sitronix: drm_dev_enter() blocks st75256_crtc_atomic_disable() on remove -- commit 0a4d4758a47b4e9c1bc202d6013889ca0bafb0a1 Author: Cyril Hrubis drm/sitronix: Add driver for Sitronix ST75256 LCD panels This commit adds a DRM driver for Sitronix ST75256 monochrome and 4-level grayscale SPI LCD panels, supporting R1, R2, and XRGB8888 framebuffers with damaged-area updates. > diff --git a/drivers/gpu/drm/sitronix/st75256.c b/drivers/gpu/drm/sitroni= x/st75256.c > new file mode 100644 > index 0000000000000..4a931208cec52 > --- /dev/null > +++ b/drivers/gpu/drm/sitronix/st75256.c [ ... ] > +static int st75256_hw_init(struct st75256_device *st75256) > +{ [ ... ] > + st75256_cmd(st75256, &err, ST75256_DISP_MODE, ST75256_MODE_GRAY); > + /* Clock divider, duty, line inversion */ > + st75256_cmd(st75256, &err, ST75256_DISP_CTRL, 0x00, panel->width - 1, 0= x01); > + if (err) > + return err; > + > + st75256->hw_mode =3D ST75256_MODE_GRAY; > + > + err =3D st75256_clear(st75256); > + > + st75256_cmd(st75256, &err, ST75256_DISP_ON); > + > + return err; > +} [Severity: Medium] Can an SPI error during st75256_hw_init() leave the controller in an inconsistent state for subsequent plane updates? Early error returns leave reset deasserted, potentially with the internal booster enabled and ST75256_EXT2 still selected while st75256->hw_mode stays 0. Because st75256_crtc_atomic_enable() returns void, st75256_plane_atomic_update() still runs, sees mode !=3D st75256->hw_mode, = and sends opcode 0xf0 without selecting ST75256_EXT1 (which is ST75256_FRAME_RATE in EXT2 instead of ST75256_DISP_MODE). In addition, st75256->hw_mode is set to ST75256_MODE_GRAY before st75256_clear() and ST75256_DISP_ON succeed. Asserting reset on error, updating hw_mode only after init succeeds, and bailing out of st75256_plane_atomic_update() when hw_mode is 0 would keep the state consistent. [ ... ] > +static int st75256_fb_blit(struct st75256_device *st75256, > + struct drm_framebuffer *fb, > + const struct iosys_map *vmap, > + const struct drm_plane_state *state, > + const struct drm_rect *damage, > + struct drm_format_conv_state *fmtcnv_state) > +{ > + unsigned int ppb =3D st75256->hw_mode =3D=3D ST75256_MODE_MONO ? 8 : 4; > + int src_x =3D state->src.x1 >> 16; > + int src_y =3D state->src.y1 >> 16; > + struct drm_rect dst =3D *damage; > + unsigned int row_len; > + u8 *tx =3D st75256->tx_buf; > + int y; > + > + /* Framebuffer to display coordinates, aligned to whole bytes */ > + drm_rect_translate(&dst, -src_x, -src_y); > + dst.x1 =3D round_down(dst.x1, ppb); > + dst.x2 =3D min_t(int, round_up(dst.x2, ppb), st75256->panel.width); > + row_len =3D drm_rect_width(&dst) / ppb; [Severity: Critical] Can fractional 16.16 source coordinates overflow st75256->tx_buf here? st75256_plane_atomic_check() does not reject fractional bits in src.x1 or src.y1. When a framebuffer taller than the panel is committed with a fractional src.y1, drm_atomic_helper_damage_iter_init() rounds plane_src.y1 down and plane_src.y2 up, producing a damage height of panel->height + 1. Because dst.y2 is not clamped to st75256->panel.height, the row loop runs panel->height + 1 times and writes panel->width / 4 bytes past the end of st75256->tx_buf in 2bpp grayscale mode. On a 256-pixel-tall panel this also truncates y2 - 1 (256) to 0 in ST75256_SET_COL_ADDR. Similarly, a damage clip on the trailing fractional column clamps dst.x1 =3D=3D dst.x2 =3D=3D panel->width without returning ea= rly, sending inverted out-of-range page bounds to ST75256_SET_PAGE_ADDR. [ ... ] > + } else { > + const u8 *src =3D (const u8 *)vmap->vaddr + fb->offsets[0] + > + (dst.x1 + src_x) / ppb; [Severity: High] Does adding fb->offsets[0] here cause an out-of-bounds read for R1 and R2 framebuffers with a non-zero offset? st75256_plane_atomic_update() passes &shadow_state->data[0] as vmap, which already had fb->offsets[0] applied by drm_gem_fb_vmap() during begin_fb_access. Adding fb->offsets[0] a second time shifts the read by 2 * fb->offsets[0], reading up to fb->offsets[0] bytes past the end of the mapped GEM buffer and corrupting display output or faulting on a guard page. > + > + for (y =3D dst.y1; y < dst.y2; y++) { > + memcpy(tx, src + (y + src_y) * fb->pitches[0], row_len); > + tx +=3D row_len; > + } > + } [Severity: Medium] Is it safe to dereference vmap->vaddr directly with memcpy() here instead of using iosys_map_memcpy_from()? DRM_GEM_SHMEM_DRIVER_OPS enables PRIME dma-buf import, and drm_gem_shmem_vmap_locked() maps imported buffers via dma_buf_vmap(), which can return an iosys_map with is_iomem set. Using plain memcpy() on I/O memory can cause alignment or bus faults on architectures such as arm64. [ ... ] > + mode =3D fb->format->format =3D=3D DRM_FORMAT_R1 ? > + ST75256_MODE_MONO : ST75256_MODE_GRAY; > + > + if (mode !=3D st75256->hw_mode) { > + ret =3D st75256_set_mode(st75256, mode); > + if (ret) > + goto err; > + /* Display RAM layout changed, repaint everything */ > + drm_rect_fp_to_int(&damage, &new_state->src); > + } else if (!drm_atomic_helper_damage_merged(old_state, new_state, &dama= ge)) { > + goto out; > + } [Severity: Medium] Can partial FB_DAMAGE_CLIPS after a CRTC enable or modeset leave the rest of the panel blank? st75256_crtc_atomic_enable() runs before st75256_plane_atomic_update() and calls st75256_hw_init(), which clears display RAM and sets hw_mode to ST75256_MODE_GRAY. When the plane uses XRGB8888 or R2 with unchanged src and partial damage clips, mode already matches hw_mode and drm_atomic_helper_damage_merged() only blits the damaged sub-rectangle onto the cleared RAM. Setting new_state->ignore_damage_clips =3D true in st75256_plane_atomic_check() when drm_atomic_crtc_needs_modeset(crtc_state) is true would force a full repaint. [ ... ] > +static void st75256_remove(struct spi_device *spi) > +{ > + struct st75256_device *st75256 =3D spi_get_drvdata(spi); > + > + drm_dev_unplug(&st75256->drm); > + drm_atomic_helper_shutdown(&st75256->drm); > +} [Severity: Medium] Does calling drm_dev_unplug() before drm_atomic_helper_shutdown() prevent st75256_crtc_atomic_disable() from powering down the panel on unload? drm_dev_unplug() sets dev->unplugged =3D true, so the drm_dev_enter() check= in st75256_crtc_atomic_disable() always returns false during drm_atomic_helper_shutdown(). As a result, backlight_disable() and st75256_hw_fini() are skipped on module unload or sysfs unbind, leaving the panel, its internal booster, and the backlight powered on. Sibling SPI drivers such as st7586 omit drm_dev_enter()/drm_dev_exit() in their atomic_disable callback so regular driver unload turns off the displa= y. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206131330.1754= 178-1-chrubis@suse.cz?part=3D2