Skip to content

Commit 830a7f5

Browse files
Junhao HeSuzuki K Poulose
authored andcommitted
coresight: ultrasoc-smb: Config SMB buffer before register sink
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]
1 parent b841128 commit 830a7f5

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/hwtracing/coresight/ultrasoc-smb.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -583,37 +583,32 @@ static int smb_probe(struct platform_device *pdev)
583583
return ret;
584584
}
585585

586+
ret = smb_config_inport(dev, true);
587+
if (ret)
588+
return ret;
589+
590+
platform_set_drvdata(pdev, drvdata);
586591
spin_lock_init(&drvdata->spinlock);
587592
drvdata->pid = -1;
588593

589594
ret = smb_register_sink(pdev, drvdata);
590595
if (ret) {
596+
smb_config_inport(&pdev->dev, false);
591597
dev_err(dev, "Failed to register SMB sink\n");
592598
return ret;
593599
}
594600

595-
ret = smb_config_inport(dev, true);
596-
if (ret) {
597-
smb_unregister_sink(drvdata);
598-
return ret;
599-
}
600-
601-
platform_set_drvdata(pdev, drvdata);
602-
603601
return 0;
604602
}
605603

606604
static int smb_remove(struct platform_device *pdev)
607605
{
608606
struct smb_drv_data *drvdata = platform_get_drvdata(pdev);
609-
int ret;
610-
611-
ret = smb_config_inport(&pdev->dev, false);
612-
if (ret)
613-
return ret;
614607

615608
smb_unregister_sink(drvdata);
616609

610+
smb_config_inport(&pdev->dev, false);
611+
617612
return 0;
618613
}
619614

0 commit comments

Comments
 (0)