Skip to content

Commit

Permalink
coresight: ultrasoc-smb: Config SMB buffer before register sink
Browse files Browse the repository at this point in the history
The SMB dirver register the enable/disable sysfs interface in function
smb_register_sink(), however the buffer depends on the following
configuration to work well. So it'll be possible for user to access an
unreset one.

Move the config buffer operation to before register_sink().
Ignore the return value, if smb_config_inport() fails. That will
cause the hardwares disable trace path to fail, should not affect
SMB driver remove. So we make smb_remove() return success,

Fixes: 06f5c29 ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
Signed-off-by: Junhao He <[email protected]>
Reviewed-by: James Clark <[email protected]>
Signed-off-by: Suzuki K Poulose <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Junhao He authored and Suzuki K Poulose committed Nov 16, 2023
1 parent b841128 commit 830a7f5
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions drivers/hwtracing/coresight/ultrasoc-smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,37 +583,32 @@ static int smb_probe(struct platform_device *pdev)
return ret;
}

ret = smb_config_inport(dev, true);
if (ret)
return ret;

platform_set_drvdata(pdev, drvdata);
spin_lock_init(&drvdata->spinlock);
drvdata->pid = -1;

ret = smb_register_sink(pdev, drvdata);
if (ret) {
smb_config_inport(&pdev->dev, false);
dev_err(dev, "Failed to register SMB sink\n");
return ret;
}

ret = smb_config_inport(dev, true);
if (ret) {
smb_unregister_sink(drvdata);
return ret;
}

platform_set_drvdata(pdev, drvdata);

return 0;
}

static int smb_remove(struct platform_device *pdev)
{
struct smb_drv_data *drvdata = platform_get_drvdata(pdev);
int ret;

ret = smb_config_inport(&pdev->dev, false);
if (ret)
return ret;

smb_unregister_sink(drvdata);

smb_config_inport(&pdev->dev, false);

return 0;
}

Expand Down

0 comments on commit 830a7f5

Please sign in to comment.