Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

remoteproc: pru: Fix potential NULL pointer dereference in pru_rproc_set_ctable()

pru_rproc_set_ctable() accessed rproc->priv before the IS_ERR_OR_NULL
check, which could lead to a null pointer dereference. Move the pru
assignment, ensuring we never dereference a NULL rproc pointer.

Fixes: 102853400321 ("remoteproc: pru: Add pru_rproc_set_ctable() function")
Cc: stable@vger.kernel.org
Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
Link: https://lore.kernel.org/r/20250923112109.1165126-1-zhen.ni@easystack.cn
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

authored by

Zhen Ni and committed by
Mathieu Poirier
d41e075b 1ae4e2db

+2 -1
+2 -1
drivers/remoteproc/pru_rproc.c
··· 340 340 */ 341 341 int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr) 342 342 { 343 - struct pru_rproc *pru = rproc->priv; 343 + struct pru_rproc *pru; 344 344 unsigned int reg; 345 345 u32 mask, set; 346 346 u16 idx; ··· 352 352 if (!rproc->dev.parent || !is_pru_rproc(rproc->dev.parent)) 353 353 return -ENODEV; 354 354 355 + pru = rproc->priv; 355 356 /* pointer is 16 bit and index is 8-bit so mask out the rest */ 356 357 idx_mask = (c >= PRU_C28) ? 0xFFFF : 0xFF; 357 358