Skip to content

Commit d41e075

Browse files
nizhen-tmathieupoirier
authored andcommitted
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: 1028534 ("remoteproc: pru: Add pru_rproc_set_ctable() function") Cc: [email protected] Signed-off-by: Zhen Ni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 1ae4e2d commit d41e075

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/remoteproc/pru_rproc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ EXPORT_SYMBOL_GPL(pru_rproc_put);
340340
*/
341341
int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr)
342342
{
343-
struct pru_rproc *pru = rproc->priv;
343+
struct pru_rproc *pru;
344344
unsigned int reg;
345345
u32 mask, set;
346346
u16 idx;
@@ -352,6 +352,7 @@ int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr)
352352
if (!rproc->dev.parent || !is_pru_rproc(rproc->dev.parent))
353353
return -ENODEV;
354354

355+
pru = rproc->priv;
355356
/* pointer is 16 bit and index is 8-bit so mask out the rest */
356357
idx_mask = (c >= PRU_C28) ? 0xFFFF : 0xFF;
357358

0 commit comments

Comments
 (0)