From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>,
linux-kernel@vger.kernel.org,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
stable@vger.kernel.org, Ammy Yi <ammy.yi@intel.com>
Subject: [GIT PULL v1 5/7] intel_th: Don't reference unassigned outputs
Date: Thu, 21 Feb 2019 17:50:04 +0200 [thread overview]
Message-ID: <20190221155006.76832-6-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20190221155006.76832-1-alexander.shishkin@linux.intel.com>
When an output port driver is removed, also remove references to it from
any masters. Failing to do this causes a NULL ptr dereference when
configuring another output port:
> BUG: unable to handle kernel NULL pointer dereference at 000000000000000d
> RIP: 0010:master_attr_store+0x9d/0x160 [intel_th_gth]
> Call Trace:
> dev_attr_store+0x1b/0x30
> sysfs_kf_write+0x3c/0x50
> kernfs_fop_write+0x125/0x1a0
> __vfs_write+0x3a/0x190
> ? __vfs_write+0x5/0x190
> ? _cond_resched+0x1a/0x50
> ? rcu_all_qs+0x5/0xb0
> ? __vfs_write+0x5/0x190
> vfs_write+0xb8/0x1b0
> ksys_write+0x55/0xc0
> __x64_sys_write+0x1a/0x20
> do_syscall_64+0x5a/0x140
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: b27a6a3f97b9 ("intel_th: Add Global Trace Hub driver")
CC: stable@vger.kernel.org # v4.4+
Reported-by: Ammy Yi <ammy.yi@intel.com>
---
drivers/hwtracing/intel_th/gth.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
index 8426b7970c14..cc287cf6eb29 100644
--- a/drivers/hwtracing/intel_th/gth.c
+++ b/drivers/hwtracing/intel_th/gth.c
@@ -607,6 +607,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
{
struct gth_device *gth = dev_get_drvdata(&thdev->dev);
int port = othdev->output.port;
+ int master;
if (thdev->host_mode)
return;
@@ -615,6 +616,9 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
othdev->output.port = -1;
othdev->output.active = false;
gth->output[port].output = NULL;
+ for (master = 0; master < TH_CONFIGURABLE_MASTERS; master++)
+ if (gth->master[master] == port)
+ gth->master[master] = -1;
spin_unlock(>h->gth_lock);
}
--
2.20.1
next prev parent reply other threads:[~2019-02-21 15:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 15:49 [GIT PULL v1 0/7] stm class/intel_th: Updates for v5.1 Alexander Shishkin
2019-02-21 15:50 ` [GIT PULL v1 1/7] intel_th: Update ABI documentation Alexander Shishkin
2019-02-21 15:50 ` [GIT PULL v1 2/7] intel_th: Mark expected switch fall-throughs Alexander Shishkin
2019-02-21 15:50 ` [GIT PULL v1 3/7] intel_th: Only create useful device nodes Alexander Shishkin
2019-02-21 15:50 ` [GIT PULL v1 4/7] intel_th: pti: Use sysfs_match_string() helper Alexander Shishkin
2019-02-21 15:50 ` Alexander Shishkin [this message]
2019-02-21 15:50 ` [GIT PULL v1 6/7] stm class: Fix an endless loop in channel allocation Alexander Shishkin
2019-02-21 15:50 ` [GIT PULL v1 7/7] stm class: Prevent division by zero Alexander Shishkin
2019-02-21 16:13 ` [GIT PULL v1 0/7] stm class/intel_th: Updates for v5.1 Greg Kroah-Hartman
2019-03-01 8:12 ` Alexander Shishkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190221155006.76832-6-alexander.shishkin@linux.intel.com \
--to=alexander.shishkin@linux.intel.com \
--cc=ammy.yi@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox