linux/drivers/hwtracing/stm
Alexander Shishkin c18614a1a1 stm class: Fix a module refcount leak in policy creation error path
Commit c7fd62bc69 ("stm class: Introduce framing protocol drivers")
adds a bug into the error path of policy creation, that would do a
module_put() on a wrong module, if one tried to create a policy for
an stm device which already has a policy, using a different protocol.
IOW,

| mkdir /config/stp-policy/dummy_stm.0:p_basic.test
| mkdir /config/stp-policy/dummy_stm.0:p_sys-t.test # puts "p_basic"
| mkdir /config/stp-policy/dummy_stm.0:p_sys-t.test # "p_basic" -> -1

throws:

| general protection fault: 0000 [#1] SMP PTI
| CPU: 3 PID: 2887 Comm: mkdir
| RIP: 0010:module_put.part.31+0xe/0x90
| Call Trace:
|  module_put+0x13/0x20
|  stm_put_protocol+0x11/0x20 [stm_core]
|  stp_policy_make+0xf1/0x210 [stm_core]
|  ? __kmalloc+0x183/0x220
|  ? configfs_mkdir+0x10d/0x4c0
|  configfs_mkdir+0x169/0x4c0
|  vfs_mkdir+0x108/0x1c0
|  do_mkdirat+0xe8/0x110
|  __x64_sys_mkdir+0x1b/0x20
|  do_syscall_64+0x5a/0x140
|  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Correct this sad mistake by calling calling 'put' on the correct
reference, which happens to match another error path in the same
function, so we consolidate the two at the same time.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: c7fd62bc69 ("stm class: Introduce framing protocol drivers")
Reported-by: Ammy Yi <ammy.yi@intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-19 20:21:06 +01:00
..
console.c stm class: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:17 +03:00
core.c stm class: Switch over to the protocol driver 2018-10-11 12:12:54 +02:00
dummy_stm.c stm class: Make dummy's master/channel ranges configurable 2018-03-28 18:47:18 +03:00
ftrace.c coresight: Moving framework and drivers to SPDX identifier 2018-05-14 16:19:59 +02:00
heartbeat.c stm class: heartbeat: Fix whitespace 2018-10-11 12:12:55 +02:00
Kconfig stm class: Add MIPI SyS-T protocol support 2018-10-11 12:12:54 +02:00
Makefile stm class: Add MIPI SyS-T protocol support 2018-10-11 12:12:54 +02:00
p_basic.c stm class: Factor out default framing protocol 2018-10-11 12:12:54 +02:00
p_sys-t.c stm class: p_sys-t: Add support for CLOCKSYNC packets 2018-10-11 12:12:54 +02:00
policy.c stm class: Fix a module refcount leak in policy creation error path 2018-12-19 20:21:06 +01:00
stm.h stm class: Add a helper for writing data packets 2018-10-11 12:12:54 +02:00