--- /dev/null
+From 2fc995a87f2efcd803438f07bfecd35cc3d90d32 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Fri, 25 Nov 2016 16:54:06 +0100
+Subject: ASoC: intel: Fix crash at suspend/resume without card registration
+
+From: Takashi Iwai <tiwai@suse.de>
+
+commit 2fc995a87f2efcd803438f07bfecd35cc3d90d32 upstream.
+
+When ASoC Intel SST Medfield driver is probed but without codec / card
+assigned, it causes an Oops and freezes the kernel at suspend/resume,
+
+ PM: Suspending system (freeze)
+ Suspending console(s) (use no_console_suspend to debug)
+ BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
+ IP: [<ffffffffc09d9409>] sst_soc_prepare+0x19/0xa0 [snd_soc_sst_mfld_platform]
+ Oops: 0000 [#1] PREEMPT SMP
+ CPU: 0 PID: 1552 Comm: systemd-sleep Tainted: G W 4.9.0-rc6-1.g5f5c2ad-default #1
+ Call Trace:
+ [<ffffffffb45318f9>] dpm_prepare+0x209/0x460
+ [<ffffffffb4531b61>] dpm_suspend_start+0x11/0x60
+ [<ffffffffb40d3cc2>] suspend_devices_and_enter+0xb2/0x710
+ [<ffffffffb40d462e>] pm_suspend+0x30e/0x390
+ [<ffffffffb40d2eba>] state_store+0x8a/0x90
+ [<ffffffffb43c670f>] kobj_attr_store+0xf/0x20
+ [<ffffffffb42b0d97>] sysfs_kf_write+0x37/0x40
+ [<ffffffffb42b02bc>] kernfs_fop_write+0x11c/0x1b0
+ [<ffffffffb422be68>] __vfs_write+0x28/0x140
+ [<ffffffffb43728a8>] ? apparmor_file_permission+0x18/0x20
+ [<ffffffffb433b2ab>] ? security_file_permission+0x3b/0xc0
+ [<ffffffffb422d095>] vfs_write+0xb5/0x1a0
+ [<ffffffffb422e3d6>] SyS_write+0x46/0xa0
+ [<ffffffffb4719fbb>] entry_SYSCALL_64_fastpath+0x1e/0xad
+
+Add proper NULL checks in the PM code of mdfld driver.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Acked-by: Vinod Koul <vinod.koul@intel.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
++++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+@@ -762,6 +762,9 @@ static int sst_soc_prepare(struct device
+ struct sst_data *drv = dev_get_drvdata(dev);
+ int i;
+
++ if (!drv->soc_card)
++ return 0;
++
+ /* suspend all pcms first */
+ snd_soc_suspend(drv->soc_card->dev);
+ snd_soc_poweroff(drv->soc_card->dev);
+@@ -784,6 +787,9 @@ static void sst_soc_complete(struct devi
+ struct sst_data *drv = dev_get_drvdata(dev);
+ int i;
+
++ if (!drv->soc_card)
++ return;
++
+ /* restart SSPs */
+ for (i = 0; i < drv->soc_card->num_rtd; i++) {
+ struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
--- /dev/null
+From bc27c01b5c46d3bfec42c96537c7a3fae0bb2cc4 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bart.vanassche@sandisk.com>
+Date: Fri, 28 Oct 2016 17:18:48 -0700
+Subject: blk-mq: Do not invoke .queue_rq() for a stopped queue
+
+From: Bart Van Assche <bart.vanassche@sandisk.com>
+
+commit bc27c01b5c46d3bfec42c96537c7a3fae0bb2cc4 upstream.
+
+The meaning of the BLK_MQ_S_STOPPED flag is "do not call
+.queue_rq()". Hence modify blk_mq_make_request() such that requests
+are queued instead of issued if a queue has been stopped.
+
+Reported-by: Ming Lei <tom.leiming@gmail.com>
+Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Ming Lei <tom.leiming@gmail.com>
+Reviewed-by: Hannes Reinecke <hare@suse.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
+Signed-off-by: Jens Axboe <axboe@fb.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ block/blk-mq.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/block/blk-mq.c
++++ b/block/blk-mq.c
+@@ -1313,9 +1313,9 @@ static blk_qc_t blk_mq_make_request(stru
+ blk_mq_put_ctx(data.ctx);
+ if (!old_rq)
+ goto done;
+- if (!blk_mq_direct_issue_request(old_rq, &cookie))
+- goto done;
+- blk_mq_insert_request(old_rq, false, true, true);
++ if (test_bit(BLK_MQ_S_STOPPED, &data.hctx->state) ||
++ blk_mq_direct_issue_request(old_rq, &cookie) != 0)
++ blk_mq_insert_request(old_rq, false, true, true);
+ goto done;
+ }
+
--- /dev/null
+From 265e9098bac02bc5e36cda21fdbad34cb5b2f48d Mon Sep 17 00:00:00 2001
+From: Ondrej Kozina <okozina@redhat.com>
+Date: Wed, 2 Nov 2016 15:02:08 +0100
+Subject: dm crypt: mark key as invalid until properly loaded
+
+From: Ondrej Kozina <okozina@redhat.com>
+
+commit 265e9098bac02bc5e36cda21fdbad34cb5b2f48d upstream.
+
+In crypt_set_key(), if a failure occurs while replacing the old key
+(e.g. tfm->setkey() fails) the key must not have DM_CRYPT_KEY_VALID flag
+set. Otherwise, the crypto layer would have an invalid key that still
+has DM_CRYPT_KEY_VALID flag set.
+
+Signed-off-by: Ondrej Kozina <okozina@redhat.com>
+Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
+Signed-off-by: Mike Snitzer <snitzer@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/md/dm-crypt.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/drivers/md/dm-crypt.c
++++ b/drivers/md/dm-crypt.c
+@@ -1500,12 +1500,15 @@ static int crypt_set_key(struct crypt_co
+ if (!cc->key_size && strcmp(key, "-"))
+ goto out;
+
++ /* clear the flag since following operations may invalidate previously valid key */
++ clear_bit(DM_CRYPT_KEY_VALID, &cc->flags);
++
+ if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
+ goto out;
+
+- set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
+-
+ r = crypt_setkey_allcpus(cc);
++ if (!r)
++ set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
+
+ out:
+ /* Hex key string not needed after here, so wipe it. */
--- /dev/null
+From bff7e067ee518f9ed7e1cbc63e4c9e01670d0b71 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <weiyj.lk@gmail.com>
+Date: Mon, 8 Aug 2016 14:09:27 +0000
+Subject: dm flakey: return -EINVAL on interval bounds error in flakey_ctr()
+
+From: Wei Yongjun <weiyj.lk@gmail.com>
+
+commit bff7e067ee518f9ed7e1cbc63e4c9e01670d0b71 upstream.
+
+Fix to return error code -EINVAL instead of 0, as is done elsewhere in
+this function.
+
+Fixes: e80d1c805a3b ("dm: do not override error code returned from dm_get_device()")
+Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
+Signed-off-by: Mike Snitzer <snitzer@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/md/dm-flakey.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/md/dm-flakey.c
++++ b/drivers/md/dm-flakey.c
+@@ -200,11 +200,13 @@ static int flakey_ctr(struct dm_target *
+
+ if (!(fc->up_interval + fc->down_interval)) {
+ ti->error = "Total (up + down) interval is zero";
++ r = -EINVAL;
+ goto bad;
+ }
+
+ if (fc->up_interval + fc->down_interval < fc->up_interval) {
+ ti->error = "Interval overflow";
++ r = -EINVAL;
+ goto bad;
+ }
+
--- /dev/null
+From 314c25c56c1ee5026cf99c570bdfe01847927acb Mon Sep 17 00:00:00 2001
+From: Benjamin Marzinski <bmarzins@redhat.com>
+Date: Wed, 30 Nov 2016 17:56:14 -0600
+Subject: dm space map metadata: fix 'struct sm_metadata' leak on failed create
+
+From: Benjamin Marzinski <bmarzins@redhat.com>
+
+commit 314c25c56c1ee5026cf99c570bdfe01847927acb upstream.
+
+In dm_sm_metadata_create() we temporarily change the dm_space_map
+operations from 'ops' (whose .destroy function deallocates the
+sm_metadata) to 'bootstrap_ops' (whose .destroy function doesn't).
+
+If dm_sm_metadata_create() fails in sm_ll_new_metadata() or
+sm_ll_extend(), it exits back to dm_tm_create_internal(), which calls
+dm_sm_destroy() with the intention of freeing the sm_metadata, but it
+doesn't (because the dm_space_map operations is still set to
+'bootstrap_ops').
+
+Fix this by setting the dm_space_map operations back to 'ops' if
+dm_sm_metadata_create() fails when it is set to 'bootstrap_ops'.
+
+Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
+Acked-by: Joe Thornber <ejt@redhat.com>
+Signed-off-by: Mike Snitzer <snitzer@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/md/persistent-data/dm-space-map-metadata.c | 14 ++++++--------
+ 1 file changed, 6 insertions(+), 8 deletions(-)
+
+--- a/drivers/md/persistent-data/dm-space-map-metadata.c
++++ b/drivers/md/persistent-data/dm-space-map-metadata.c
+@@ -775,17 +775,15 @@ int dm_sm_metadata_create(struct dm_spac
+ memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm));
+
+ r = sm_ll_new_metadata(&smm->ll, tm);
++ if (!r) {
++ if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
++ nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
++ r = sm_ll_extend(&smm->ll, nr_blocks);
++ }
++ memcpy(&smm->sm, &ops, sizeof(smm->sm));
+ if (r)
+ return r;
+
+- if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
+- nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
+- r = sm_ll_extend(&smm->ll, nr_blocks);
+- if (r)
+- return r;
+-
+- memcpy(&smm->sm, &ops, sizeof(smm->sm));
+-
+ /*
+ * Now we need to update the newly created data structures with the
+ * allocated blocks that they were built from.
fs-exec-apply-cloexec-before-changing-dumpable-task-flags.patch
exec-ensure-mm-user_ns-contains-the-execed-files.patch
usb-gadget-composite-always-set-ep-mult-to-a-sensible-value.patch
+blk-mq-do-not-invoke-.queue_rq-for-a-stopped-queue.patch
+dm-flakey-return-einval-on-interval-bounds-error-in-flakey_ctr.patch
+dm-crypt-mark-key-as-invalid-until-properly-loaded.patch
+dm-space-map-metadata-fix-struct-sm_metadata-leak-on-failed-create.patch
+asoc-intel-fix-crash-at-suspend-resume-without-card-registration.patch