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

coresight: Handle build path error

Enabling a component via sysfs (echo 1 > enable_source), would
trigger building a path from the enabled sources to the sink.
If there is an error in the process (e.g, sink not enabled or
the device (CPU corresponding to ETM) is not online), we never report
failure, except for leaving a message in the dmesg.

Do proper error checking for the build path and return the error.

Before:
$ echo 0 > /sys/devices/system/cpu/cpu2/online
$ echo 1 > /sys/devices/cs_etm/cpu2/enable_source
$ echo $?
0

After:
$ echo 0 > /sys/devices/system/cpu/cpu2/online
$ echo 1 > /sys/devices/cs_etm/cpu2/enable_source
-bash: echo: write error: No such device or address

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Suzuki K Poulose and committed by
Greg Kroah-Hartman
5014e904 f3b8172f

+6 -3
+6 -3
drivers/hwtracing/coresight/coresight.c
··· 425 425 struct list_head *coresight_build_path(struct coresight_device *csdev) 426 426 { 427 427 struct list_head *path; 428 + int rc; 428 429 429 430 path = kzalloc(sizeof(struct list_head), GFP_KERNEL); 430 431 if (!path) ··· 433 432 434 433 INIT_LIST_HEAD(path); 435 434 436 - if (_coresight_build_path(csdev, path)) { 435 + rc = _coresight_build_path(csdev, path); 436 + if (rc) { 437 437 kfree(path); 438 - path = NULL; 438 + return ERR_PTR(rc); 439 439 } 440 440 441 441 return path; ··· 509 507 goto out; 510 508 511 509 path = coresight_build_path(csdev); 512 - if (!path) { 510 + if (IS_ERR(path)) { 513 511 pr_err("building path(s) failed\n"); 512 + ret = PTR_ERR(path); 514 513 goto out; 515 514 } 516 515