Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Wed, 26 May 2021 12:06:44
Message-Id: 1622030788.014d68f108d944f0d19d2491bc11fb16d772ebfb.mpagano@gentoo
1 commit: 014d68f108d944f0d19d2491bc11fb16d772ebfb
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 26 12:06:28 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed May 26 12:06:28 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=014d68f1
7
8 Linux patch 5.4.122
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1121_linux-5.4.122.patch | 2145 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2149 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index fd8dcff..35230a5 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -527,6 +527,10 @@ Patch: 1120_linux-5.4.121.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.121
23
24 +Patch: 1121_linux-5.4.122.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.122
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1121_linux-5.4.122.patch b/1121_linux-5.4.122.patch
33 new file mode 100644
34 index 0000000..bb00c38
35 --- /dev/null
36 +++ b/1121_linux-5.4.122.patch
37 @@ -0,0 +1,2145 @@
38 +diff --git a/Makefile b/Makefile
39 +index 18b4cebe55642..9b64ebcf45312 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 5
45 + PATCHLEVEL = 4
46 +-SUBLEVEL = 121
47 ++SUBLEVEL = 122
48 + EXTRAVERSION =
49 + NAME = Kleptomaniac Octopus
50 +
51 +diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
52 +index d668f5be3a995..ae104eb4becc7 100644
53 +--- a/arch/openrisc/kernel/setup.c
54 ++++ b/arch/openrisc/kernel/setup.c
55 +@@ -274,6 +274,8 @@ void calibrate_delay(void)
56 + pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
57 + loops_per_jiffy / (500000 / HZ),
58 + (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
59 ++
60 ++ of_node_put(cpu);
61 + }
62 +
63 + void __init setup_arch(char **cmdline_p)
64 +diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
65 +index 6626c84f66d16..1c3b77e17e4b0 100644
66 +--- a/drivers/cdrom/gdrom.c
67 ++++ b/drivers/cdrom/gdrom.c
68 +@@ -740,6 +740,13 @@ static const struct blk_mq_ops gdrom_mq_ops = {
69 + static int probe_gdrom(struct platform_device *devptr)
70 + {
71 + int err;
72 ++
73 ++ /*
74 ++ * Ensure our "one" device is initialized properly in case of previous
75 ++ * usages of it
76 ++ */
77 ++ memset(&gd, 0, sizeof(gd));
78 ++
79 + /* Start the device */
80 + if (gdrom_execute_diagnostic() != 1) {
81 + pr_warning("ATA Probe for GDROM failed\n");
82 +@@ -828,6 +835,8 @@ static int remove_gdrom(struct platform_device *devptr)
83 + if (gdrom_major)
84 + unregister_blkdev(gdrom_major, GDROM_DEV_NAME);
85 + unregister_cdrom(gd.cd_info);
86 ++ kfree(gd.cd_info);
87 ++ kfree(gd.toc);
88 +
89 + return 0;
90 + }
91 +@@ -843,7 +852,7 @@ static struct platform_driver gdrom_driver = {
92 + static int __init init_gdrom(void)
93 + {
94 + int rc;
95 +- gd.toc = NULL;
96 ++
97 + rc = platform_driver_register(&gdrom_driver);
98 + if (rc)
99 + return rc;
100 +@@ -859,8 +868,6 @@ static void __exit exit_gdrom(void)
101 + {
102 + platform_device_unregister(pd);
103 + platform_driver_unregister(&gdrom_driver);
104 +- kfree(gd.toc);
105 +- kfree(gd.cd_info);
106 + }
107 +
108 + module_init(init_gdrom);
109 +diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
110 +index a80c331c3a6e5..e2995ec144010 100644
111 +--- a/drivers/firmware/arm_scpi.c
112 ++++ b/drivers/firmware/arm_scpi.c
113 +@@ -552,8 +552,10 @@ static unsigned long scpi_clk_get_val(u16 clk_id)
114 +
115 + ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id,
116 + sizeof(le_clk_id), &rate, sizeof(rate));
117 ++ if (ret)
118 ++ return 0;
119 +
120 +- return ret ? ret : le32_to_cpu(rate);
121 ++ return le32_to_cpu(rate);
122 + }
123 +
124 + static int scpi_clk_set_val(u16 clk_id, unsigned long rate)
125 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
126 +index d17edc850427a..1d8739a4fbcad 100644
127 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
128 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
129 +@@ -190,9 +190,10 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_2[] =
130 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG, 0xffffffff, 0x20000000),
131 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xffffffff, 0x00000420),
132 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0xffffffff, 0x00000200),
133 +- SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0xffffffff, 0x04800000),
134 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0xffffffff, 0x04900000),
135 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DFSM_TILES_IN_FLIGHT, 0x0000ffff, 0x0000003f),
136 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_LAST_OF_BURST_CONFIG, 0xffffffff, 0x03860204),
137 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0x0c1800ff, 0x00000044),
138 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCR_GENERAL_CNTL, 0x1ff0ffff, 0x00000500),
139 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmGE_PRIV_CONTROL, 0x00007fff, 0x000001fe),
140 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL1_PIPE_STEER, 0xffffffff, 0xe4e4e4e4),
141 +@@ -210,12 +211,13 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_2[] =
142 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0x00000820, 0x00000820),
143 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000),
144 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_SPARE, 0xffffffff, 0xffff3101),
145 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x001f0000, 0x00070104),
146 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ALU_CLK_CTRL, 0xffffffff, 0xffffffff),
147 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_ARB_CONFIG, 0x00000133, 0x00000130),
148 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_LDS_CLK_CTRL, 0xffffffff, 0xffffffff),
149 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfff7ffff, 0x01030000),
150 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CNTL, 0xffdf80ff, 0x479c0010),
151 +- SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0xffffffff, 0x00800000)
152 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0xffffffff, 0x00c00000)
153 + };
154 +
155 + static const struct soc15_reg_golden golden_settings_gc_10_1_nv14[] =
156 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
157 +index 90dcc7afc9c43..06cdc22b5501d 100644
158 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
159 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
160 +@@ -4661,7 +4661,7 @@ static void gfx_v9_0_update_3d_clock_gating(struct amdgpu_device *adev,
161 + amdgpu_gfx_rlc_enter_safe_mode(adev);
162 +
163 + /* Enable 3D CGCG/CGLS */
164 +- if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGCG)) {
165 ++ if (enable) {
166 + /* write cmd to clear cgcg/cgls ov */
167 + def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
168 + /* unset CGCG override */
169 +@@ -4673,8 +4673,12 @@ static void gfx_v9_0_update_3d_clock_gating(struct amdgpu_device *adev,
170 + /* enable 3Dcgcg FSM(0x0000363f) */
171 + def = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
172 +
173 +- data = (0x36 << RLC_CGCG_CGLS_CTRL_3D__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
174 +- RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK;
175 ++ if (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGCG)
176 ++ data = (0x36 << RLC_CGCG_CGLS_CTRL_3D__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
177 ++ RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK;
178 ++ else
179 ++ data = 0x0 << RLC_CGCG_CGLS_CTRL_3D__CGCG_GFX_IDLE_THRESHOLD__SHIFT;
180 ++
181 + if (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGLS)
182 + data |= (0x000F << RLC_CGCG_CGLS_CTRL_3D__CGLS_REP_COMPANSAT_DELAY__SHIFT) |
183 + RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK;
184 +diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
185 +index 465351184bc3e..60180eca84a60 100644
186 +--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
187 ++++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
188 +@@ -100,6 +100,10 @@ static const struct soc15_reg_golden golden_settings_sdma_nv14[] = {
189 +
190 + static const struct soc15_reg_golden golden_settings_sdma_nv12[] = {
191 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA0_RLC3_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000),
192 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA0_GB_ADDR_CONFIG, 0x001877ff, 0x00000044),
193 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x001877ff, 0x00000044),
194 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA1_GB_ADDR_CONFIG, 0x001877ff, 0x00000044),
195 ++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x001877ff, 0x00000044),
196 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA1_RLC3_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000),
197 + };
198 +
199 +diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
200 +index 41631271d64ca..6ff1d308623a7 100644
201 +--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
202 ++++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
203 +@@ -1132,7 +1132,6 @@ static int soc15_common_early_init(void *handle)
204 + adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
205 + AMD_CG_SUPPORT_GFX_MGLS |
206 + AMD_CG_SUPPORT_GFX_CP_LS |
207 +- AMD_CG_SUPPORT_GFX_3D_CGCG |
208 + AMD_CG_SUPPORT_GFX_3D_CGLS |
209 + AMD_CG_SUPPORT_GFX_CGCG |
210 + AMD_CG_SUPPORT_GFX_CGLS |
211 +@@ -1152,7 +1151,6 @@ static int soc15_common_early_init(void *handle)
212 + AMD_CG_SUPPORT_GFX_MGLS |
213 + AMD_CG_SUPPORT_GFX_RLC_LS |
214 + AMD_CG_SUPPORT_GFX_CP_LS |
215 +- AMD_CG_SUPPORT_GFX_3D_CGCG |
216 + AMD_CG_SUPPORT_GFX_3D_CGLS |
217 + AMD_CG_SUPPORT_GFX_CGCG |
218 + AMD_CG_SUPPORT_GFX_CGLS |
219 +diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
220 +index 80520cef76173..e34cdc42575d8 100644
221 +--- a/drivers/hwmon/lm80.c
222 ++++ b/drivers/hwmon/lm80.c
223 +@@ -597,7 +597,6 @@ static int lm80_probe(struct i2c_client *client,
224 + struct device *dev = &client->dev;
225 + struct device *hwmon_dev;
226 + struct lm80_data *data;
227 +- int rv;
228 +
229 + data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL);
230 + if (!data)
231 +@@ -610,14 +609,8 @@ static int lm80_probe(struct i2c_client *client,
232 + lm80_init_client(client);
233 +
234 + /* A few vars need to be filled upon startup */
235 +- rv = lm80_read_value(client, LM80_REG_FAN_MIN(1));
236 +- if (rv < 0)
237 +- return rv;
238 +- data->fan[f_min][0] = rv;
239 +- rv = lm80_read_value(client, LM80_REG_FAN_MIN(2));
240 +- if (rv < 0)
241 +- return rv;
242 +- data->fan[f_min][1] = rv;
243 ++ data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1));
244 ++ data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
245 +
246 + hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
247 + data, lm80_groups);
248 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
249 +index ecac62a7b59e8..92428990f0ccc 100644
250 +--- a/drivers/infiniband/core/cma.c
251 ++++ b/drivers/infiniband/core/cma.c
252 +@@ -530,6 +530,7 @@ static void cma_release_dev(struct rdma_id_private *id_priv)
253 + list_del(&id_priv->list);
254 + cma_deref_dev(id_priv->cma_dev);
255 + id_priv->cma_dev = NULL;
256 ++ id_priv->id.device = NULL;
257 + if (id_priv->id.route.addr.dev_addr.sgid_attr) {
258 + rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
259 + id_priv->id.route.addr.dev_addr.sgid_attr = NULL;
260 +@@ -1871,6 +1872,7 @@ void rdma_destroy_id(struct rdma_cm_id *id)
261 + iw_destroy_cm_id(id_priv->cm_id.iw);
262 + }
263 + cma_leave_mc_groups(id_priv);
264 ++ rdma_restrack_del(&id_priv->res);
265 + cma_release_dev(id_priv);
266 + }
267 +
268 +@@ -3580,7 +3582,7 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
269 + }
270 +
271 + id_priv->backlog = backlog;
272 +- if (id->device) {
273 ++ if (id_priv->cma_dev) {
274 + if (rdma_cap_ib_cm(id->device, 1)) {
275 + ret = cma_ib_listen(id_priv);
276 + if (ret)
277 +diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
278 +index 2a3f2f01028d3..fd351bdec3f64 100644
279 +--- a/drivers/infiniband/core/uverbs_std_types_device.c
280 ++++ b/drivers/infiniband/core/uverbs_std_types_device.c
281 +@@ -110,8 +110,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_INFO_HANDLES)(
282 + return ret;
283 +
284 + uapi_object = uapi_get_object(attrs->ufile->device->uapi, object_id);
285 +- if (!uapi_object)
286 +- return -EINVAL;
287 ++ if (IS_ERR(uapi_object))
288 ++ return PTR_ERR(uapi_object);
289 +
290 + handles = gather_objects_handle(attrs->ufile, uapi_object, attrs,
291 + out_len, &total);
292 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
293 +index e2656b68ec222..a173737cb0222 100644
294 +--- a/drivers/infiniband/hw/mlx5/main.c
295 ++++ b/drivers/infiniband/hw/mlx5/main.c
296 +@@ -6879,6 +6879,7 @@ static void *mlx5_ib_add_slave_port(struct mlx5_core_dev *mdev)
297 +
298 + if (bound) {
299 + rdma_roce_rescan_device(&dev->ib_dev);
300 ++ mpi->ibdev->ib_active = true;
301 + break;
302 + }
303 + }
304 +diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
305 +index f85273883794b..d427a343c09f6 100644
306 +--- a/drivers/infiniband/sw/rxe/rxe_qp.c
307 ++++ b/drivers/infiniband/sw/rxe/rxe_qp.c
308 +@@ -260,6 +260,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
309 + if (err) {
310 + vfree(qp->sq.queue->buf);
311 + kfree(qp->sq.queue);
312 ++ qp->sq.queue = NULL;
313 + return err;
314 + }
315 +
316 +@@ -313,6 +314,7 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
317 + if (err) {
318 + vfree(qp->rq.queue->buf);
319 + kfree(qp->rq.queue);
320 ++ qp->rq.queue = NULL;
321 + return err;
322 + }
323 + }
324 +@@ -373,6 +375,11 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
325 + err2:
326 + rxe_queue_cleanup(qp->sq.queue);
327 + err1:
328 ++ qp->pd = NULL;
329 ++ qp->rcq = NULL;
330 ++ qp->scq = NULL;
331 ++ qp->srq = NULL;
332 ++
333 + if (srq)
334 + rxe_drop_ref(srq);
335 + rxe_drop_ref(scq);
336 +diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
337 +index 2c3704f0f10fa..b9ca54e372b47 100644
338 +--- a/drivers/infiniband/sw/siw/siw_verbs.c
339 ++++ b/drivers/infiniband/sw/siw/siw_verbs.c
340 +@@ -314,7 +314,6 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
341 + struct siw_ucontext *uctx =
342 + rdma_udata_to_drv_context(udata, struct siw_ucontext,
343 + base_ucontext);
344 +- struct siw_cq *scq = NULL, *rcq = NULL;
345 + unsigned long flags;
346 + int num_sqe, num_rqe, rv = 0;
347 +
348 +@@ -353,10 +352,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
349 + rv = -EINVAL;
350 + goto err_out;
351 + }
352 +- scq = to_siw_cq(attrs->send_cq);
353 +- rcq = to_siw_cq(attrs->recv_cq);
354 +
355 +- if (!scq || (!rcq && !attrs->srq)) {
356 ++ if (!attrs->send_cq || (!attrs->recv_cq && !attrs->srq)) {
357 + siw_dbg(base_dev, "send CQ or receive CQ invalid\n");
358 + rv = -EINVAL;
359 + goto err_out;
360 +@@ -400,7 +397,7 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
361 + else {
362 + /* Zero sized SQ is not supported */
363 + rv = -EINVAL;
364 +- goto err_out;
365 ++ goto err_out_xa;
366 + }
367 + if (num_rqe)
368 + num_rqe = roundup_pow_of_two(num_rqe);
369 +@@ -423,8 +420,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
370 + }
371 + }
372 + qp->pd = pd;
373 +- qp->scq = scq;
374 +- qp->rcq = rcq;
375 ++ qp->scq = to_siw_cq(attrs->send_cq);
376 ++ qp->rcq = to_siw_cq(attrs->recv_cq);
377 +
378 + if (attrs->srq) {
379 + /*
380 +diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
381 +index d0b931a136b96..82e781abde293 100644
382 +--- a/drivers/leds/leds-lp5523.c
383 ++++ b/drivers/leds/leds-lp5523.c
384 +@@ -307,7 +307,7 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
385 + usleep_range(3000, 6000);
386 + ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
387 + if (ret)
388 +- return ret;
389 ++ goto out;
390 + status &= LP5523_ENG_STATUS_MASK;
391 +
392 + if (status != LP5523_ENG_STATUS_MASK) {
393 +diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
394 +index 0164c9ca984ba..add7d4ce41802 100644
395 +--- a/drivers/md/dm-snap.c
396 ++++ b/drivers/md/dm-snap.c
397 +@@ -1408,6 +1408,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
398 +
399 + if (!s->store->chunk_size) {
400 + ti->error = "Chunk size not set";
401 ++ r = -EINVAL;
402 + goto bad_read_metadata;
403 + }
404 +
405 +diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
406 +index af3c8d405509e..ae9a5f3e1beca 100644
407 +--- a/drivers/media/platform/rcar_drif.c
408 ++++ b/drivers/media/platform/rcar_drif.c
409 +@@ -911,7 +911,6 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv,
410 + {
411 + struct rcar_drif_sdr *sdr = video_drvdata(file);
412 +
413 +- memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
414 + f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
415 + f->fmt.sdr.buffersize = sdr->fmt->buffersize;
416 +
417 +diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c
418 +index 2bdf560ee681b..0f9ea75b0b189 100644
419 +--- a/drivers/misc/ics932s401.c
420 ++++ b/drivers/misc/ics932s401.c
421 +@@ -134,7 +134,7 @@ static struct ics932s401_data *ics932s401_update_device(struct device *dev)
422 + for (i = 0; i < NUM_MIRRORED_REGS; i++) {
423 + temp = i2c_smbus_read_word_data(client, regs_to_copy[i]);
424 + if (temp < 0)
425 +- data->regs[regs_to_copy[i]] = 0;
426 ++ temp = 0;
427 + data->regs[regs_to_copy[i]] = temp >> 8;
428 + }
429 +
430 +diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
431 +index fd76aa672e020..4437ea4ec8596 100644
432 +--- a/drivers/mmc/host/sdhci-pci-gli.c
433 ++++ b/drivers/mmc/host/sdhci-pci-gli.c
434 +@@ -318,8 +318,13 @@ static void sdhci_gli_voltage_switch(struct sdhci_host *host)
435 + *
436 + * Wait 5ms after set 1.8V signal enable in Host Control 2 register
437 + * to ensure 1.8V signal enable bit is set by GL9750/GL9755.
438 ++ *
439 ++ * ...however, the controller in the NUC10i3FNK4 (a 9755) requires
440 ++ * slightly longer than 5ms before the control register reports that
441 ++ * 1.8V is ready, and far longer still before the card will actually
442 ++ * work reliably.
443 + */
444 +- usleep_range(5000, 5500);
445 ++ usleep_range(100000, 110000);
446 + }
447 +
448 + static void sdhci_gl9750_reset(struct sdhci_host *host, u8 mask)
449 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
450 +index a4cd6f2cfb862..4fb3dcb038196 100644
451 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
452 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
453 +@@ -1049,7 +1049,7 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode)
454 + for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) {
455 + skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE);
456 + if (!skb)
457 +- break;
458 ++ goto error;
459 + qlcnic_create_loopback_buff(skb->data, adapter->mac_addr);
460 + skb_put(skb, QLCNIC_ILB_PKT_SIZE);
461 + adapter->ahw->diag_cnt = 0;
462 +@@ -1073,6 +1073,7 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode)
463 + cnt++;
464 + }
465 + if (cnt != i) {
466 ++error:
467 + dev_err(&adapter->pdev->dev,
468 + "LB Test: failed, TX[%d], RX[%d]\n", i, cnt);
469 + if (mode != QLCNIC_ILB_MODE)
470 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
471 +index 65a3e3b5facef..f87cab39fa0e8 100644
472 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
473 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
474 +@@ -30,7 +30,7 @@ struct sunxi_priv_data {
475 + static int sun7i_gmac_init(struct platform_device *pdev, void *priv)
476 + {
477 + struct sunxi_priv_data *gmac = priv;
478 +- int ret;
479 ++ int ret = 0;
480 +
481 + if (gmac->regulator) {
482 + ret = regulator_enable(gmac->regulator);
483 +@@ -51,11 +51,11 @@ static int sun7i_gmac_init(struct platform_device *pdev, void *priv)
484 + } else {
485 + clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE);
486 + ret = clk_prepare(gmac->tx_clk);
487 +- if (ret)
488 +- return ret;
489 ++ if (ret && gmac->regulator)
490 ++ regulator_disable(gmac->regulator);
491 + }
492 +
493 +- return 0;
494 ++ return ret;
495 + }
496 +
497 + static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)
498 +diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
499 +index 2911740af7061..595f560937a71 100644
500 +--- a/drivers/net/ethernet/sun/niu.c
501 ++++ b/drivers/net/ethernet/sun/niu.c
502 +@@ -8144,10 +8144,10 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
503 + "VPD_SCAN: Reading in property [%s] len[%d]\n",
504 + namebuf, prop_len);
505 + for (i = 0; i < prop_len; i++) {
506 +- err = niu_pci_eeprom_read(np, off + i);
507 +- if (err >= 0)
508 +- *prop_buf = err;
509 +- ++prop_buf;
510 ++ err = niu_pci_eeprom_read(np, off + i);
511 ++ if (err < 0)
512 ++ return err;
513 ++ *prop_buf++ = err;
514 + }
515 + }
516 +
517 +@@ -8158,14 +8158,14 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
518 + }
519 +
520 + /* ESPC_PIO_EN_ENABLE must be set */
521 +-static void niu_pci_vpd_fetch(struct niu *np, u32 start)
522 ++static int niu_pci_vpd_fetch(struct niu *np, u32 start)
523 + {
524 + u32 offset;
525 + int err;
526 +
527 + err = niu_pci_eeprom_read16_swp(np, start + 1);
528 + if (err < 0)
529 +- return;
530 ++ return err;
531 +
532 + offset = err + 3;
533 +
534 +@@ -8174,12 +8174,14 @@ static void niu_pci_vpd_fetch(struct niu *np, u32 start)
535 + u32 end;
536 +
537 + err = niu_pci_eeprom_read(np, here);
538 ++ if (err < 0)
539 ++ return err;
540 + if (err != 0x90)
541 +- return;
542 ++ return -EINVAL;
543 +
544 + err = niu_pci_eeprom_read16_swp(np, here + 1);
545 + if (err < 0)
546 +- return;
547 ++ return err;
548 +
549 + here = start + offset + 3;
550 + end = start + offset + err;
551 +@@ -8187,9 +8189,12 @@ static void niu_pci_vpd_fetch(struct niu *np, u32 start)
552 + offset += err;
553 +
554 + err = niu_pci_vpd_scan_props(np, here, end);
555 +- if (err < 0 || err == 1)
556 +- return;
557 ++ if (err < 0)
558 ++ return err;
559 ++ if (err == 1)
560 ++ return -EINVAL;
561 + }
562 ++ return 0;
563 + }
564 +
565 + /* ESPC_PIO_EN_ENABLE must be set */
566 +@@ -9280,8 +9285,11 @@ static int niu_get_invariants(struct niu *np)
567 + offset = niu_pci_vpd_offset(np);
568 + netif_printk(np, probe, KERN_DEBUG, np->dev,
569 + "%s() VPD offset [%08x]\n", __func__, offset);
570 +- if (offset)
571 +- niu_pci_vpd_fetch(np, offset);
572 ++ if (offset) {
573 ++ err = niu_pci_vpd_fetch(np, offset);
574 ++ if (err < 0)
575 ++ return err;
576 ++ }
577 + nw64(ESPC_PIO_EN, 0);
578 +
579 + if (np->flags & NIU_FLAGS_VPD_VALID) {
580 +diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
581 +index ac746c322554b..c9ad6761032ae 100644
582 +--- a/drivers/net/wireless/realtek/rtlwifi/base.c
583 ++++ b/drivers/net/wireless/realtek/rtlwifi/base.c
584 +@@ -436,9 +436,14 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
585 + }
586 + }
587 +
588 +-static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
589 ++static int _rtl_init_deferred_work(struct ieee80211_hw *hw)
590 + {
591 + struct rtl_priv *rtlpriv = rtl_priv(hw);
592 ++ struct workqueue_struct *wq;
593 ++
594 ++ wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
595 ++ if (!wq)
596 ++ return -ENOMEM;
597 +
598 + /* <1> timer */
599 + timer_setup(&rtlpriv->works.watchdog_timer,
600 +@@ -447,11 +452,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
601 + rtl_easy_concurrent_retrytimer_callback, 0);
602 + /* <2> work queue */
603 + rtlpriv->works.hw = hw;
604 +- rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
605 +- if (unlikely(!rtlpriv->works.rtl_wq)) {
606 +- pr_err("Failed to allocate work queue\n");
607 +- return;
608 +- }
609 ++ rtlpriv->works.rtl_wq = wq;
610 +
611 + INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
612 + (void *)rtl_watchdog_wq_callback);
613 +@@ -465,6 +466,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
614 + (void *)rtl_fwevt_wq_callback);
615 + INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq,
616 + (void *)rtl_c2hcmd_wq_callback);
617 ++ return 0;
618 + }
619 +
620 + void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq)
621 +@@ -564,9 +566,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
622 + rtlmac->link_state = MAC80211_NOLINK;
623 +
624 + /* <6> init deferred work */
625 +- _rtl_init_deferred_work(hw);
626 +-
627 +- return 0;
628 ++ return _rtl_init_deferred_work(hw);
629 + }
630 + EXPORT_SYMBOL_GPL(rtl_init_core);
631 +
632 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
633 +index 6041511b8b76d..710ab45eb679d 100644
634 +--- a/drivers/nvme/host/core.c
635 ++++ b/drivers/nvme/host/core.c
636 +@@ -2904,7 +2904,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
637 + ctrl->hmmaxd = le16_to_cpu(id->hmmaxd);
638 + }
639 +
640 +- ret = nvme_mpath_init(ctrl, id);
641 ++ ret = nvme_mpath_init_identify(ctrl, id);
642 + kfree(id);
643 +
644 + if (ret < 0)
645 +@@ -4145,6 +4145,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
646 + min(default_ps_max_latency_us, (unsigned long)S32_MAX));
647 +
648 + nvme_fault_inject_init(&ctrl->fault_inject, dev_name(ctrl->device));
649 ++ nvme_mpath_init_ctrl(ctrl);
650 +
651 + return 0;
652 + out_free_name:
653 +diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
654 +index 855edc4e12440..590b040e90a34 100644
655 +--- a/drivers/nvme/host/multipath.c
656 ++++ b/drivers/nvme/host/multipath.c
657 +@@ -718,9 +718,18 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
658 + put_disk(head->disk);
659 + }
660 +
661 +-int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
662 ++void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl)
663 + {
664 +- int error;
665 ++ mutex_init(&ctrl->ana_lock);
666 ++ timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
667 ++ INIT_WORK(&ctrl->ana_work, nvme_ana_work);
668 ++}
669 ++
670 ++int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
671 ++{
672 ++ size_t max_transfer_size = ctrl->max_hw_sectors << SECTOR_SHIFT;
673 ++ size_t ana_log_size;
674 ++ int error = 0;
675 +
676 + /* check if multipath is enabled and we have the capability */
677 + if (!multipath || !ctrl->subsys || !(ctrl->subsys->cmic & (1 << 3)))
678 +@@ -731,37 +740,31 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
679 + ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
680 + ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
681 +
682 +- mutex_init(&ctrl->ana_lock);
683 +- timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
684 +- ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
685 +- ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc);
686 +- ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32);
687 +-
688 +- if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) {
689 ++ ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
690 ++ ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc) +
691 ++ ctrl->max_namespaces * sizeof(__le32);
692 ++ if (ana_log_size > max_transfer_size) {
693 + dev_err(ctrl->device,
694 +- "ANA log page size (%zd) larger than MDTS (%d).\n",
695 +- ctrl->ana_log_size,
696 +- ctrl->max_hw_sectors << SECTOR_SHIFT);
697 ++ "ANA log page size (%zd) larger than MDTS (%zd).\n",
698 ++ ana_log_size, max_transfer_size);
699 + dev_err(ctrl->device, "disabling ANA support.\n");
700 +- return 0;
701 ++ goto out_uninit;
702 + }
703 +-
704 +- INIT_WORK(&ctrl->ana_work, nvme_ana_work);
705 +- kfree(ctrl->ana_log_buf);
706 +- ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL);
707 +- if (!ctrl->ana_log_buf) {
708 +- error = -ENOMEM;
709 +- goto out;
710 ++ if (ana_log_size > ctrl->ana_log_size) {
711 ++ nvme_mpath_stop(ctrl);
712 ++ kfree(ctrl->ana_log_buf);
713 ++ ctrl->ana_log_buf = kmalloc(ana_log_size, GFP_KERNEL);
714 ++ if (!ctrl->ana_log_buf)
715 ++ return -ENOMEM;
716 + }
717 +-
718 ++ ctrl->ana_log_size = ana_log_size;
719 + error = nvme_read_ana_log(ctrl);
720 + if (error)
721 +- goto out_free_ana_log_buf;
722 ++ goto out_uninit;
723 + return 0;
724 +-out_free_ana_log_buf:
725 +- kfree(ctrl->ana_log_buf);
726 +- ctrl->ana_log_buf = NULL;
727 +-out:
728 ++
729 ++out_uninit:
730 ++ nvme_mpath_uninit(ctrl);
731 + return error;
732 + }
733 +
734 +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
735 +index 62e5401865fee..2df90d4355b9a 100644
736 +--- a/drivers/nvme/host/nvme.h
737 ++++ b/drivers/nvme/host/nvme.h
738 +@@ -549,7 +549,8 @@ void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
739 + int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
740 + void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id);
741 + void nvme_mpath_remove_disk(struct nvme_ns_head *head);
742 +-int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
743 ++int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
744 ++void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl);
745 + void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
746 + void nvme_mpath_stop(struct nvme_ctrl *ctrl);
747 + bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
748 +@@ -636,7 +637,10 @@ static inline void nvme_trace_bio_complete(struct request *req,
749 + blk_status_t status)
750 + {
751 + }
752 +-static inline int nvme_mpath_init(struct nvme_ctrl *ctrl,
753 ++static inline void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl)
754 ++{
755 ++}
756 ++static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl,
757 + struct nvme_id_ctrl *id)
758 + {
759 + if (ctrl->subsys->cmic & (1 << 3))
760 +diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
761 +index 05453f5d14486..6ca17a0babae2 100644
762 +--- a/drivers/nvme/target/io-cmd-file.c
763 ++++ b/drivers/nvme/target/io-cmd-file.c
764 +@@ -38,9 +38,11 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
765 +
766 + ns->file = filp_open(ns->device_path, flags, 0);
767 + if (IS_ERR(ns->file)) {
768 +- pr_err("failed to open file %s: (%ld)\n",
769 +- ns->device_path, PTR_ERR(ns->file));
770 +- return PTR_ERR(ns->file);
771 ++ ret = PTR_ERR(ns->file);
772 ++ pr_err("failed to open file %s: (%d)\n",
773 ++ ns->device_path, ret);
774 ++ ns->file = NULL;
775 ++ return ret;
776 + }
777 +
778 + ret = vfs_getattr(&ns->file->f_path,
779 +diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
780 +index 5739a9669b291..92bda873d44a4 100644
781 +--- a/drivers/platform/mellanox/mlxbf-tmfifo.c
782 ++++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
783 +@@ -294,6 +294,9 @@ mlxbf_tmfifo_get_next_desc(struct mlxbf_tmfifo_vring *vring)
784 + if (vring->next_avail == virtio16_to_cpu(vdev, vr->avail->idx))
785 + return NULL;
786 +
787 ++ /* Make sure 'avail->idx' is visible already. */
788 ++ virtio_rmb(false);
789 ++
790 + idx = vring->next_avail % vr->num;
791 + head = virtio16_to_cpu(vdev, vr->avail->ring[idx]);
792 + if (WARN_ON(head >= vr->num))
793 +@@ -322,7 +325,7 @@ static void mlxbf_tmfifo_release_desc(struct mlxbf_tmfifo_vring *vring,
794 + * done or not. Add a memory barrier here to make sure the update above
795 + * completes before updating the idx.
796 + */
797 +- mb();
798 ++ virtio_mb(false);
799 + vr->used->idx = cpu_to_virtio16(vdev, vr_idx + 1);
800 + }
801 +
802 +@@ -730,6 +733,12 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,
803 + desc = NULL;
804 + fifo->vring[is_rx] = NULL;
805 +
806 ++ /*
807 ++ * Make sure the load/store are in order before
808 ++ * returning back to virtio.
809 ++ */
810 ++ virtio_mb(false);
811 ++
812 + /* Notify upper layer that packet is done. */
813 + spin_lock_irqsave(&fifo->spin_lock[is_rx], flags);
814 + vring_interrupt(0, vring->vq);
815 +diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c
816 +index 27a298b7c541b..c97bd4a452422 100644
817 +--- a/drivers/platform/x86/dell-smbios-wmi.c
818 ++++ b/drivers/platform/x86/dell-smbios-wmi.c
819 +@@ -271,7 +271,8 @@ int init_dell_smbios_wmi(void)
820 +
821 + void exit_dell_smbios_wmi(void)
822 + {
823 +- wmi_driver_unregister(&dell_smbios_wmi_driver);
824 ++ if (wmi_supported)
825 ++ wmi_driver_unregister(&dell_smbios_wmi_driver);
826 + }
827 +
828 + MODULE_DEVICE_TABLE(wmi, dell_smbios_wmi_id_table);
829 +diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c
830 +index 50ec53d67a4c0..db4c265287ae6 100644
831 +--- a/drivers/rapidio/rio_cm.c
832 ++++ b/drivers/rapidio/rio_cm.c
833 +@@ -2127,6 +2127,14 @@ static int riocm_add_mport(struct device *dev,
834 + return -ENODEV;
835 + }
836 +
837 ++ cm->rx_wq = create_workqueue(DRV_NAME "/rxq");
838 ++ if (!cm->rx_wq) {
839 ++ rio_release_inb_mbox(mport, cmbox);
840 ++ rio_release_outb_mbox(mport, cmbox);
841 ++ kfree(cm);
842 ++ return -ENOMEM;
843 ++ }
844 ++
845 + /*
846 + * Allocate and register inbound messaging buffers to be ready
847 + * to receive channel and system management requests
848 +@@ -2137,15 +2145,6 @@ static int riocm_add_mport(struct device *dev,
849 + cm->rx_slots = RIOCM_RX_RING_SIZE;
850 + mutex_init(&cm->rx_lock);
851 + riocm_rx_fill(cm, RIOCM_RX_RING_SIZE);
852 +- cm->rx_wq = create_workqueue(DRV_NAME "/rxq");
853 +- if (!cm->rx_wq) {
854 +- riocm_error("failed to allocate IBMBOX_%d on %s",
855 +- cmbox, mport->name);
856 +- rio_release_outb_mbox(mport, cmbox);
857 +- kfree(cm);
858 +- return -ENOMEM;
859 +- }
860 +-
861 + INIT_WORK(&cm->rx_work, rio_ibmsg_handler);
862 +
863 + cm->tx_slot = 0;
864 +diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
865 +index c855d013ba8aa..de567a025133c 100644
866 +--- a/drivers/scsi/qla2xxx/qla_nx.c
867 ++++ b/drivers/scsi/qla2xxx/qla_nx.c
868 +@@ -1113,7 +1113,8 @@ qla82xx_write_flash_dword(struct qla_hw_data *ha, uint32_t flashaddr,
869 + return ret;
870 + }
871 +
872 +- if (qla82xx_flash_set_write_enable(ha))
873 ++ ret = qla82xx_flash_set_write_enable(ha);
874 ++ if (ret < 0)
875 + goto done_write;
876 +
877 + qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_WDATA, data);
878 +diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
879 +index 6bbb1679bb91c..9903ce9f066cf 100644
880 +--- a/drivers/scsi/ufs/ufs-hisi.c
881 ++++ b/drivers/scsi/ufs/ufs-hisi.c
882 +@@ -481,21 +481,24 @@ static int ufs_hisi_init_common(struct ufs_hba *hba)
883 + host->hba = hba;
884 + ufshcd_set_variant(hba, host);
885 +
886 +- host->rst = devm_reset_control_get(dev, "rst");
887 ++ host->rst = devm_reset_control_get(dev, "rst");
888 + if (IS_ERR(host->rst)) {
889 + dev_err(dev, "%s: failed to get reset control\n", __func__);
890 +- return PTR_ERR(host->rst);
891 ++ err = PTR_ERR(host->rst);
892 ++ goto error;
893 + }
894 +
895 + ufs_hisi_set_pm_lvl(hba);
896 +
897 + err = ufs_hisi_get_resource(host);
898 +- if (err) {
899 +- ufshcd_set_variant(hba, NULL);
900 +- return err;
901 +- }
902 ++ if (err)
903 ++ goto error;
904 +
905 + return 0;
906 ++
907 ++error:
908 ++ ufshcd_set_variant(hba, NULL);
909 ++ return err;
910 + }
911 +
912 + static int ufs_hi3660_init(struct ufs_hba *hba)
913 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
914 +index 25112c2fe2db6..0429ba5d7d23c 100644
915 +--- a/drivers/scsi/ufs/ufshcd.c
916 ++++ b/drivers/scsi/ufs/ufshcd.c
917 +@@ -2615,7 +2615,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
918 + * ufshcd_exec_dev_cmd - API for sending device management requests
919 + * @hba: UFS hba
920 + * @cmd_type: specifies the type (NOP, Query...)
921 +- * @timeout: time in seconds
922 ++ * @timeout: timeout in milliseconds
923 + *
924 + * NOTE: Since there is only one available tag for device management commands,
925 + * it is expected you hold the hba->dev_cmd.lock mutex.
926 +@@ -2645,6 +2645,9 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
927 + }
928 + tag = req->tag;
929 + WARN_ON_ONCE(!ufshcd_valid_tag(hba, tag));
930 ++ /* Set the timeout such that the SCSI error handler is not activated. */
931 ++ req->timeout = msecs_to_jiffies(2 * timeout);
932 ++ blk_mq_start_request(req);
933 +
934 + init_completion(&wait);
935 + lrbp = &hba->lrb[tag];
936 +diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
937 +index e006f40ffdc04..5e6f661943eb1 100644
938 +--- a/drivers/tty/serial/mvebu-uart.c
939 ++++ b/drivers/tty/serial/mvebu-uart.c
940 +@@ -818,9 +818,6 @@ static int mvebu_uart_probe(struct platform_device *pdev)
941 + return -EINVAL;
942 + }
943 +
944 +- if (!match)
945 +- return -ENODEV;
946 +-
947 + /* Assume that all UART ports have a DT alias or none has */
948 + id = of_alias_get_id(pdev->dev.of_node, "serial");
949 + if (!pdev->dev.of_node || id < 0)
950 +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
951 +index 564e1fa2e4c94..6f013d7f5bd0f 100644
952 +--- a/drivers/tty/vt/vt.c
953 ++++ b/drivers/tty/vt/vt.c
954 +@@ -1166,7 +1166,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
955 + /* Resizes the resolution of the display adapater */
956 + int err = 0;
957 +
958 +- if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize)
959 ++ if (vc->vc_sw->con_resize)
960 + err = vc->vc_sw->con_resize(vc, width, height, user);
961 +
962 + return err;
963 +diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
964 +index 4f51be17427c0..b5d2ad900ec09 100644
965 +--- a/drivers/tty/vt/vt_ioctl.c
966 ++++ b/drivers/tty/vt/vt_ioctl.c
967 +@@ -895,17 +895,17 @@ int vt_ioctl(struct tty_struct *tty,
968 + if (vcp) {
969 + int ret;
970 + int save_scan_lines = vcp->vc_scan_lines;
971 +- int save_font_height = vcp->vc_font.height;
972 ++ int save_cell_height = vcp->vc_cell_height;
973 +
974 + if (v.v_vlin)
975 + vcp->vc_scan_lines = v.v_vlin;
976 + if (v.v_clin)
977 +- vcp->vc_font.height = v.v_clin;
978 ++ vcp->vc_cell_height = v.v_clin;
979 + vcp->vc_resize_user = 1;
980 + ret = vc_resize(vcp, v.v_cols, v.v_rows);
981 + if (ret) {
982 + vcp->vc_scan_lines = save_scan_lines;
983 +- vcp->vc_font.height = save_font_height;
984 ++ vcp->vc_cell_height = save_cell_height;
985 + console_unlock();
986 + return ret;
987 + }
988 +diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
989 +index 3c5169eb23f5c..bdf3932ee3f20 100644
990 +--- a/drivers/uio/uio_hv_generic.c
991 ++++ b/drivers/uio/uio_hv_generic.c
992 +@@ -296,8 +296,10 @@ hv_uio_probe(struct hv_device *dev,
993 +
994 + ret = vmbus_establish_gpadl(channel, pdata->recv_buf,
995 + RECV_BUFFER_SIZE, &pdata->recv_gpadl);
996 +- if (ret)
997 ++ if (ret) {
998 ++ vfree(pdata->recv_buf);
999 + goto fail_close;
1000 ++ }
1001 +
1002 + /* put Global Physical Address Label in name */
1003 + snprintf(pdata->recv_name, sizeof(pdata->recv_name),
1004 +@@ -316,8 +318,10 @@ hv_uio_probe(struct hv_device *dev,
1005 +
1006 + ret = vmbus_establish_gpadl(channel, pdata->send_buf,
1007 + SEND_BUFFER_SIZE, &pdata->send_gpadl);
1008 +- if (ret)
1009 ++ if (ret) {
1010 ++ vfree(pdata->send_buf);
1011 + goto fail_close;
1012 ++ }
1013 +
1014 + snprintf(pdata->send_name, sizeof(pdata->send_name),
1015 + "send:%u", pdata->send_gpadl);
1016 +diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
1017 +index 55507df335bdd..a992d922b3a71 100644
1018 +--- a/drivers/video/console/vgacon.c
1019 ++++ b/drivers/video/console/vgacon.c
1020 +@@ -384,7 +384,7 @@ static void vgacon_init(struct vc_data *c, int init)
1021 + vc_resize(c, vga_video_num_columns, vga_video_num_lines);
1022 +
1023 + c->vc_scan_lines = vga_scan_lines;
1024 +- c->vc_font.height = vga_video_font_height;
1025 ++ c->vc_font.height = c->vc_cell_height = vga_video_font_height;
1026 + c->vc_complement_mask = 0x7700;
1027 + if (vga_512_chars)
1028 + c->vc_hi_font_mask = 0x0800;
1029 +@@ -517,32 +517,32 @@ static void vgacon_cursor(struct vc_data *c, int mode)
1030 + switch (c->vc_cursor_type & 0x0f) {
1031 + case CUR_UNDERLINE:
1032 + vgacon_set_cursor_size(c->vc_x,
1033 +- c->vc_font.height -
1034 +- (c->vc_font.height <
1035 ++ c->vc_cell_height -
1036 ++ (c->vc_cell_height <
1037 + 10 ? 2 : 3),
1038 +- c->vc_font.height -
1039 +- (c->vc_font.height <
1040 ++ c->vc_cell_height -
1041 ++ (c->vc_cell_height <
1042 + 10 ? 1 : 2));
1043 + break;
1044 + case CUR_TWO_THIRDS:
1045 + vgacon_set_cursor_size(c->vc_x,
1046 +- c->vc_font.height / 3,
1047 +- c->vc_font.height -
1048 +- (c->vc_font.height <
1049 ++ c->vc_cell_height / 3,
1050 ++ c->vc_cell_height -
1051 ++ (c->vc_cell_height <
1052 + 10 ? 1 : 2));
1053 + break;
1054 + case CUR_LOWER_THIRD:
1055 + vgacon_set_cursor_size(c->vc_x,
1056 +- (c->vc_font.height * 2) / 3,
1057 +- c->vc_font.height -
1058 +- (c->vc_font.height <
1059 ++ (c->vc_cell_height * 2) / 3,
1060 ++ c->vc_cell_height -
1061 ++ (c->vc_cell_height <
1062 + 10 ? 1 : 2));
1063 + break;
1064 + case CUR_LOWER_HALF:
1065 + vgacon_set_cursor_size(c->vc_x,
1066 +- c->vc_font.height / 2,
1067 +- c->vc_font.height -
1068 +- (c->vc_font.height <
1069 ++ c->vc_cell_height / 2,
1070 ++ c->vc_cell_height -
1071 ++ (c->vc_cell_height <
1072 + 10 ? 1 : 2));
1073 + break;
1074 + case CUR_NONE:
1075 +@@ -553,7 +553,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
1076 + break;
1077 + default:
1078 + vgacon_set_cursor_size(c->vc_x, 1,
1079 +- c->vc_font.height);
1080 ++ c->vc_cell_height);
1081 + break;
1082 + }
1083 + break;
1084 +@@ -564,13 +564,13 @@ static int vgacon_doresize(struct vc_data *c,
1085 + unsigned int width, unsigned int height)
1086 + {
1087 + unsigned long flags;
1088 +- unsigned int scanlines = height * c->vc_font.height;
1089 ++ unsigned int scanlines = height * c->vc_cell_height;
1090 + u8 scanlines_lo = 0, r7 = 0, vsync_end = 0, mode, max_scan;
1091 +
1092 + raw_spin_lock_irqsave(&vga_lock, flags);
1093 +
1094 + vgacon_xres = width * VGA_FONTWIDTH;
1095 +- vgacon_yres = height * c->vc_font.height;
1096 ++ vgacon_yres = height * c->vc_cell_height;
1097 + if (vga_video_type >= VIDEO_TYPE_VGAC) {
1098 + outb_p(VGA_CRTC_MAX_SCAN, vga_video_port_reg);
1099 + max_scan = inb_p(vga_video_port_val);
1100 +@@ -625,9 +625,9 @@ static int vgacon_doresize(struct vc_data *c,
1101 + static int vgacon_switch(struct vc_data *c)
1102 + {
1103 + int x = c->vc_cols * VGA_FONTWIDTH;
1104 +- int y = c->vc_rows * c->vc_font.height;
1105 ++ int y = c->vc_rows * c->vc_cell_height;
1106 + int rows = screen_info.orig_video_lines * vga_default_font_height/
1107 +- c->vc_font.height;
1108 ++ c->vc_cell_height;
1109 + /*
1110 + * We need to save screen size here as it's the only way
1111 + * we can spot the screen has been resized and we need to
1112 +@@ -1058,7 +1058,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)
1113 + cursor_size_lastto = 0;
1114 + c->vc_sw->con_cursor(c, CM_DRAW);
1115 + }
1116 +- c->vc_font.height = fontheight;
1117 ++ c->vc_font.height = c->vc_cell_height = fontheight;
1118 + vc_resize(c, 0, rows); /* Adjust console size */
1119 + }
1120 + }
1121 +@@ -1106,12 +1106,20 @@ static int vgacon_resize(struct vc_data *c, unsigned int width,
1122 + if ((width << 1) * height > vga_vram_size)
1123 + return -EINVAL;
1124 +
1125 ++ if (user) {
1126 ++ /*
1127 ++ * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed
1128 ++ * the video mode! Set the new defaults then and go away.
1129 ++ */
1130 ++ screen_info.orig_video_cols = width;
1131 ++ screen_info.orig_video_lines = height;
1132 ++ vga_default_font_height = c->vc_cell_height;
1133 ++ return 0;
1134 ++ }
1135 + if (width % 2 || width > screen_info.orig_video_cols ||
1136 + height > (screen_info.orig_video_lines * vga_default_font_height)/
1137 +- c->vc_font.height)
1138 +- /* let svgatextmode tinker with video timings and
1139 +- return success */
1140 +- return (user) ? 0 : -EINVAL;
1141 ++ c->vc_cell_height)
1142 ++ return -EINVAL;
1143 +
1144 + if (con_is_visible(c) && !vga_is_gfx) /* who knows */
1145 + vgacon_doresize(c, width, height);
1146 +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
1147 +index 0a9202176ffc9..75b7705140673 100644
1148 +--- a/drivers/video/fbdev/core/fbcon.c
1149 ++++ b/drivers/video/fbdev/core/fbcon.c
1150 +@@ -2058,7 +2058,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1151 + return -EINVAL;
1152 +
1153 + DPRINTK("resize now %ix%i\n", var.xres, var.yres);
1154 +- if (con_is_visible(vc)) {
1155 ++ if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
1156 + var.activate = FB_ACTIVATE_NOW |
1157 + FB_ACTIVATE_FORCE;
1158 + fb_set_var(info, &var);
1159 +diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c
1160 +index 59e1cae579481..03c0b1b8747b9 100644
1161 +--- a/drivers/video/fbdev/hgafb.c
1162 ++++ b/drivers/video/fbdev/hgafb.c
1163 +@@ -286,7 +286,7 @@ static int hga_card_detect(void)
1164 +
1165 + hga_vram = ioremap(0xb0000, hga_vram_len);
1166 + if (!hga_vram)
1167 +- goto error;
1168 ++ return -ENOMEM;
1169 +
1170 + if (request_region(0x3b0, 12, "hgafb"))
1171 + release_io_ports = 1;
1172 +@@ -346,13 +346,18 @@ static int hga_card_detect(void)
1173 + hga_type_name = "Hercules";
1174 + break;
1175 + }
1176 +- return 1;
1177 ++ return 0;
1178 + error:
1179 + if (release_io_ports)
1180 + release_region(0x3b0, 12);
1181 + if (release_io_port)
1182 + release_region(0x3bf, 1);
1183 +- return 0;
1184 ++
1185 ++ iounmap(hga_vram);
1186 ++
1187 ++ pr_err("hgafb: HGA card not detected.\n");
1188 ++
1189 ++ return -EINVAL;
1190 + }
1191 +
1192 + /**
1193 +@@ -550,13 +555,11 @@ static struct fb_ops hgafb_ops = {
1194 + static int hgafb_probe(struct platform_device *pdev)
1195 + {
1196 + struct fb_info *info;
1197 ++ int ret;
1198 +
1199 +- if (! hga_card_detect()) {
1200 +- printk(KERN_INFO "hgafb: HGA card not detected.\n");
1201 +- if (hga_vram)
1202 +- iounmap(hga_vram);
1203 +- return -EINVAL;
1204 +- }
1205 ++ ret = hga_card_detect();
1206 ++ if (ret)
1207 ++ return ret;
1208 +
1209 + printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n",
1210 + hga_type_name, hga_vram_len/1024);
1211 +diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c
1212 +index 58b01c7d90560..5f610d4929ddb 100644
1213 +--- a/drivers/video/fbdev/imsttfb.c
1214 ++++ b/drivers/video/fbdev/imsttfb.c
1215 +@@ -1512,11 +1512,6 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1216 + info->fix.smem_start = addr;
1217 + info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ?
1218 + 0x400000 : 0x800000);
1219 +- if (!info->screen_base) {
1220 +- release_mem_region(addr, size);
1221 +- framebuffer_release(info);
1222 +- return -ENOMEM;
1223 +- }
1224 + info->fix.mmio_start = addr + 0x800000;
1225 + par->dc_regs = ioremap(addr + 0x800000, 0x1000);
1226 + par->cmap_regs_phys = addr + 0x840000;
1227 +diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
1228 +index 7fb65836230ac..a255b08aff4d9 100644
1229 +--- a/drivers/xen/xen-pciback/xenbus.c
1230 ++++ b/drivers/xen/xen-pciback/xenbus.c
1231 +@@ -358,7 +358,8 @@ out:
1232 + return err;
1233 + }
1234 +
1235 +-static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
1236 ++static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
1237 ++ enum xenbus_state state)
1238 + {
1239 + int err = 0;
1240 + int num_devs;
1241 +@@ -372,9 +373,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
1242 + dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
1243 +
1244 + mutex_lock(&pdev->dev_lock);
1245 +- /* Make sure we only reconfigure once */
1246 +- if (xenbus_read_driver_state(pdev->xdev->nodename) !=
1247 +- XenbusStateReconfiguring)
1248 ++ if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
1249 + goto out;
1250 +
1251 + err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
1252 +@@ -499,6 +498,10 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
1253 + }
1254 + }
1255 +
1256 ++ if (state != XenbusStateReconfiguring)
1257 ++ /* Make sure we only reconfigure once. */
1258 ++ goto out;
1259 ++
1260 + err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured);
1261 + if (err) {
1262 + xenbus_dev_fatal(pdev->xdev, err,
1263 +@@ -524,7 +527,7 @@ static void xen_pcibk_frontend_changed(struct xenbus_device *xdev,
1264 + break;
1265 +
1266 + case XenbusStateReconfiguring:
1267 +- xen_pcibk_reconfigure(pdev);
1268 ++ xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring);
1269 + break;
1270 +
1271 + case XenbusStateConnected:
1272 +@@ -663,6 +666,15 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
1273 + xen_pcibk_setup_backend(pdev);
1274 + break;
1275 +
1276 ++ case XenbusStateInitialised:
1277 ++ /*
1278 ++ * We typically move to Initialised when the first device was
1279 ++ * added. Hence subsequent devices getting added may need
1280 ++ * reconfiguring.
1281 ++ */
1282 ++ xen_pcibk_reconfigure(pdev, XenbusStateInitialised);
1283 ++ break;
1284 ++
1285 + default:
1286 + break;
1287 + }
1288 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
1289 +index b36a4d144bec0..8ea9559c1919a 100644
1290 +--- a/fs/btrfs/inode.c
1291 ++++ b/fs/btrfs/inode.c
1292 +@@ -3571,6 +3571,7 @@ void btrfs_run_delayed_iputs(struct btrfs_fs_info *fs_info)
1293 + inode = list_first_entry(&fs_info->delayed_iputs,
1294 + struct btrfs_inode, delayed_iput);
1295 + run_delayed_iput_locked(fs_info, inode);
1296 ++ cond_resched_lock(&fs_info->delayed_iput_lock);
1297 + }
1298 + spin_unlock(&fs_info->delayed_iput_lock);
1299 + }
1300 +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
1301 +index 997a106f28d37..bf6b4f71dc58f 100644
1302 +--- a/fs/cifs/smb2ops.c
1303 ++++ b/fs/cifs/smb2ops.c
1304 +@@ -1673,6 +1673,8 @@ smb2_copychunk_range(const unsigned int xid,
1305 + cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
1306 +
1307 + /* Request server copy to target from src identified by key */
1308 ++ kfree(retbuf);
1309 ++ retbuf = NULL;
1310 + rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
1311 + trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
1312 + true /* is_fsctl */, (char *)pcchunk,
1313 +diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
1314 +index a064b408d8416..f91db24bbf3bc 100644
1315 +--- a/fs/ecryptfs/crypto.c
1316 ++++ b/fs/ecryptfs/crypto.c
1317 +@@ -311,10 +311,8 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
1318 + struct extent_crypt_result ecr;
1319 + int rc = 0;
1320 +
1321 +- if (!crypt_stat || !crypt_stat->tfm
1322 +- || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED))
1323 +- return -EINVAL;
1324 +-
1325 ++ BUG_ON(!crypt_stat || !crypt_stat->tfm
1326 ++ || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED));
1327 + if (unlikely(ecryptfs_verbosity > 0)) {
1328 + ecryptfs_printk(KERN_DEBUG, "Key size [%zd]; key:\n",
1329 + crypt_stat->key_size);
1330 +diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
1331 +index d0d8a9795dd62..6a30e54c11282 100644
1332 +--- a/fs/ext4/verity.c
1333 ++++ b/fs/ext4/verity.c
1334 +@@ -198,55 +198,76 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc,
1335 + struct inode *inode = file_inode(filp);
1336 + const int credits = 2; /* superblock and inode for ext4_orphan_del() */
1337 + handle_t *handle;
1338 ++ struct ext4_iloc iloc;
1339 + int err = 0;
1340 +- int err2;
1341 +
1342 +- if (desc != NULL) {
1343 +- /* Succeeded; write the verity descriptor. */
1344 +- err = ext4_write_verity_descriptor(inode, desc, desc_size,
1345 +- merkle_tree_size);
1346 +-
1347 +- /* Write all pages before clearing VERITY_IN_PROGRESS. */
1348 +- if (!err)
1349 +- err = filemap_write_and_wait(inode->i_mapping);
1350 +- }
1351 ++ /*
1352 ++ * If an error already occurred (which fs/verity/ signals by passing
1353 ++ * desc == NULL), then only clean-up is needed.
1354 ++ */
1355 ++ if (desc == NULL)
1356 ++ goto cleanup;
1357 +
1358 +- /* If we failed, truncate anything we wrote past i_size. */
1359 +- if (desc == NULL || err)
1360 +- ext4_truncate(inode);
1361 ++ /* Append the verity descriptor. */
1362 ++ err = ext4_write_verity_descriptor(inode, desc, desc_size,
1363 ++ merkle_tree_size);
1364 ++ if (err)
1365 ++ goto cleanup;
1366 +
1367 + /*
1368 +- * We must always clean up by clearing EXT4_STATE_VERITY_IN_PROGRESS and
1369 +- * deleting the inode from the orphan list, even if something failed.
1370 +- * If everything succeeded, we'll also set the verity bit in the same
1371 +- * transaction.
1372 ++ * Write all pages (both data and verity metadata). Note that this must
1373 ++ * happen before clearing EXT4_STATE_VERITY_IN_PROGRESS; otherwise pages
1374 ++ * beyond i_size won't be written properly. For crash consistency, this
1375 ++ * also must happen before the verity inode flag gets persisted.
1376 + */
1377 ++ err = filemap_write_and_wait(inode->i_mapping);
1378 ++ if (err)
1379 ++ goto cleanup;
1380 +
1381 +- ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
1382 ++ /*
1383 ++ * Finally, set the verity inode flag and remove the inode from the
1384 ++ * orphan list (in a single transaction).
1385 ++ */
1386 +
1387 + handle = ext4_journal_start(inode, EXT4_HT_INODE, credits);
1388 + if (IS_ERR(handle)) {
1389 +- ext4_orphan_del(NULL, inode);
1390 +- return PTR_ERR(handle);
1391 ++ err = PTR_ERR(handle);
1392 ++ goto cleanup;
1393 + }
1394 +
1395 +- err2 = ext4_orphan_del(handle, inode);
1396 +- if (err2)
1397 +- goto out_stop;
1398 ++ err = ext4_orphan_del(handle, inode);
1399 ++ if (err)
1400 ++ goto stop_and_cleanup;
1401 +
1402 +- if (desc != NULL && !err) {
1403 +- struct ext4_iloc iloc;
1404 ++ err = ext4_reserve_inode_write(handle, inode, &iloc);
1405 ++ if (err)
1406 ++ goto stop_and_cleanup;
1407 +
1408 +- err = ext4_reserve_inode_write(handle, inode, &iloc);
1409 +- if (err)
1410 +- goto out_stop;
1411 +- ext4_set_inode_flag(inode, EXT4_INODE_VERITY);
1412 +- ext4_set_inode_flags(inode);
1413 +- err = ext4_mark_iloc_dirty(handle, inode, &iloc);
1414 +- }
1415 +-out_stop:
1416 ++ ext4_set_inode_flag(inode, EXT4_INODE_VERITY);
1417 ++ ext4_set_inode_flags(inode);
1418 ++ err = ext4_mark_iloc_dirty(handle, inode, &iloc);
1419 ++ if (err)
1420 ++ goto stop_and_cleanup;
1421 ++
1422 ++ ext4_journal_stop(handle);
1423 ++
1424 ++ ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
1425 ++ return 0;
1426 ++
1427 ++stop_and_cleanup:
1428 + ext4_journal_stop(handle);
1429 +- return err ?: err2;
1430 ++cleanup:
1431 ++ /*
1432 ++ * Verity failed to be enabled, so clean up by truncating any verity
1433 ++ * metadata that was written beyond i_size (both from cache and from
1434 ++ * disk), removing the inode from the orphan list (if it wasn't done
1435 ++ * already), and clearing EXT4_STATE_VERITY_IN_PROGRESS.
1436 ++ */
1437 ++ truncate_inode_pages(inode->i_mapping, inode->i_size);
1438 ++ ext4_truncate(inode);
1439 ++ ext4_orphan_del(NULL, inode);
1440 ++ ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
1441 ++ return err;
1442 + }
1443 +
1444 + static int ext4_get_verity_descriptor_location(struct inode *inode,
1445 +diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
1446 +index 24d4c16e3ae03..717f51e1b1dfa 100644
1447 +--- a/include/linux/console_struct.h
1448 ++++ b/include/linux/console_struct.h
1449 +@@ -62,6 +62,7 @@ struct vc_data {
1450 + unsigned int vc_rows;
1451 + unsigned int vc_size_row; /* Bytes per row */
1452 + unsigned int vc_scan_lines; /* # of scan lines */
1453 ++ unsigned int vc_cell_height; /* CRTC character cell height */
1454 + unsigned long vc_origin; /* [!] Start of real screen */
1455 + unsigned long vc_scr_end; /* [!] End of real screen */
1456 + unsigned long vc_visible_origin; /* [!] Top of visible window */
1457 +diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
1458 +index 771d4ca96dda7..4fe40910f471b 100644
1459 +--- a/kernel/locking/mutex-debug.c
1460 ++++ b/kernel/locking/mutex-debug.c
1461 +@@ -57,7 +57,7 @@ void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1462 + task->blocked_on = waiter;
1463 + }
1464 +
1465 +-void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1466 ++void debug_mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1467 + struct task_struct *task)
1468 + {
1469 + DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
1470 +@@ -65,7 +65,7 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1471 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
1472 + task->blocked_on = NULL;
1473 +
1474 +- list_del_init(&waiter->list);
1475 ++ INIT_LIST_HEAD(&waiter->list);
1476 + waiter->task = NULL;
1477 + }
1478 +
1479 +diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
1480 +index 1edd3f45a4ecb..53e631e1d76da 100644
1481 +--- a/kernel/locking/mutex-debug.h
1482 ++++ b/kernel/locking/mutex-debug.h
1483 +@@ -22,7 +22,7 @@ extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
1484 + extern void debug_mutex_add_waiter(struct mutex *lock,
1485 + struct mutex_waiter *waiter,
1486 + struct task_struct *task);
1487 +-extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1488 ++extern void debug_mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1489 + struct task_struct *task);
1490 + extern void debug_mutex_unlock(struct mutex *lock);
1491 + extern void debug_mutex_init(struct mutex *lock, const char *name,
1492 +diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
1493 +index 07a9f9f46e035..c0c7784f074b2 100644
1494 +--- a/kernel/locking/mutex.c
1495 ++++ b/kernel/locking/mutex.c
1496 +@@ -204,7 +204,7 @@ static inline bool __mutex_waiter_is_first(struct mutex *lock, struct mutex_wait
1497 + * Add @waiter to a given location in the lock wait_list and set the
1498 + * FLAG_WAITERS flag if it's the first waiter.
1499 + */
1500 +-static void __sched
1501 ++static void
1502 + __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1503 + struct list_head *list)
1504 + {
1505 +@@ -215,6 +215,16 @@ __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
1506 + __mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
1507 + }
1508 +
1509 ++static void
1510 ++__mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter)
1511 ++{
1512 ++ list_del(&waiter->list);
1513 ++ if (likely(list_empty(&lock->wait_list)))
1514 ++ __mutex_clear_flag(lock, MUTEX_FLAGS);
1515 ++
1516 ++ debug_mutex_remove_waiter(lock, waiter, current);
1517 ++}
1518 ++
1519 + /*
1520 + * Give up ownership to a specific task, when @task = NULL, this is equivalent
1521 + * to a regular unlock. Sets PICKUP on a handoff, clears HANDOF, preserves
1522 +@@ -1071,9 +1081,7 @@ acquired:
1523 + __ww_mutex_check_waiters(lock, ww_ctx);
1524 + }
1525 +
1526 +- mutex_remove_waiter(lock, &waiter, current);
1527 +- if (likely(list_empty(&lock->wait_list)))
1528 +- __mutex_clear_flag(lock, MUTEX_FLAGS);
1529 ++ __mutex_remove_waiter(lock, &waiter);
1530 +
1531 + debug_mutex_free_waiter(&waiter);
1532 +
1533 +@@ -1090,7 +1098,7 @@ skip_wait:
1534 +
1535 + err:
1536 + __set_current_state(TASK_RUNNING);
1537 +- mutex_remove_waiter(lock, &waiter, current);
1538 ++ __mutex_remove_waiter(lock, &waiter);
1539 + err_early_kill:
1540 + spin_unlock(&lock->wait_lock);
1541 + debug_mutex_free_waiter(&waiter);
1542 +diff --git a/kernel/locking/mutex.h b/kernel/locking/mutex.h
1543 +index 1c2287d3fa719..f0c710b1d1927 100644
1544 +--- a/kernel/locking/mutex.h
1545 ++++ b/kernel/locking/mutex.h
1546 +@@ -10,12 +10,10 @@
1547 + * !CONFIG_DEBUG_MUTEXES case. Most of them are NOPs:
1548 + */
1549 +
1550 +-#define mutex_remove_waiter(lock, waiter, task) \
1551 +- __list_del((waiter)->list.prev, (waiter)->list.next)
1552 +-
1553 + #define debug_mutex_wake_waiter(lock, waiter) do { } while (0)
1554 + #define debug_mutex_free_waiter(waiter) do { } while (0)
1555 + #define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0)
1556 ++#define debug_mutex_remove_waiter(lock, waiter, ti) do { } while (0)
1557 + #define debug_mutex_unlock(lock) do { } while (0)
1558 + #define debug_mutex_init(lock, name, key) do { } while (0)
1559 +
1560 +diff --git a/kernel/ptrace.c b/kernel/ptrace.c
1561 +index 79de1294f8ebd..eb4d04cb3aaf5 100644
1562 +--- a/kernel/ptrace.c
1563 ++++ b/kernel/ptrace.c
1564 +@@ -169,6 +169,21 @@ void __ptrace_unlink(struct task_struct *child)
1565 + spin_unlock(&child->sighand->siglock);
1566 + }
1567 +
1568 ++static bool looks_like_a_spurious_pid(struct task_struct *task)
1569 ++{
1570 ++ if (task->exit_code != ((PTRACE_EVENT_EXEC << 8) | SIGTRAP))
1571 ++ return false;
1572 ++
1573 ++ if (task_pid_vnr(task) == task->ptrace_message)
1574 ++ return false;
1575 ++ /*
1576 ++ * The tracee changed its pid but the PTRACE_EVENT_EXEC event
1577 ++ * was not wait()'ed, most probably debugger targets the old
1578 ++ * leader which was destroyed in de_thread().
1579 ++ */
1580 ++ return true;
1581 ++}
1582 ++
1583 + /* Ensure that nothing can wake it up, even SIGKILL */
1584 + static bool ptrace_freeze_traced(struct task_struct *task)
1585 + {
1586 +@@ -179,7 +194,8 @@ static bool ptrace_freeze_traced(struct task_struct *task)
1587 + return ret;
1588 +
1589 + spin_lock_irq(&task->sighand->siglock);
1590 +- if (task_is_traced(task) && !__fatal_signal_pending(task)) {
1591 ++ if (task_is_traced(task) && !looks_like_a_spurious_pid(task) &&
1592 ++ !__fatal_signal_pending(task)) {
1593 + task->state = __TASK_TRACED;
1594 + ret = true;
1595 + }
1596 +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
1597 +index e693fee08623c..82e76ff01267a 100644
1598 +--- a/net/bluetooth/l2cap_sock.c
1599 ++++ b/net/bluetooth/l2cap_sock.c
1600 +@@ -426,6 +426,20 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
1601 + break;
1602 + }
1603 +
1604 ++ /* Only BR/EDR modes are supported here */
1605 ++ switch (chan->mode) {
1606 ++ case L2CAP_MODE_BASIC:
1607 ++ case L2CAP_MODE_ERTM:
1608 ++ case L2CAP_MODE_STREAMING:
1609 ++ break;
1610 ++ default:
1611 ++ err = -EINVAL;
1612 ++ break;
1613 ++ }
1614 ++
1615 ++ if (err < 0)
1616 ++ break;
1617 ++
1618 + memset(&opts, 0, sizeof(opts));
1619 + opts.imtu = chan->imtu;
1620 + opts.omtu = chan->omtu;
1621 +@@ -685,10 +699,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
1622 + break;
1623 + }
1624 +
1625 +- chan->mode = opts.mode;
1626 +- switch (chan->mode) {
1627 +- case L2CAP_MODE_LE_FLOWCTL:
1628 +- break;
1629 ++ /* Only BR/EDR modes are supported here */
1630 ++ switch (opts.mode) {
1631 + case L2CAP_MODE_BASIC:
1632 + clear_bit(CONF_STATE2_DEVICE, &chan->conf_state);
1633 + break;
1634 +@@ -702,6 +714,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
1635 + break;
1636 + }
1637 +
1638 ++ if (err < 0)
1639 ++ break;
1640 ++
1641 ++ chan->mode = opts.mode;
1642 + chan->imtu = opts.imtu;
1643 + chan->omtu = opts.omtu;
1644 + chan->fcs = opts.fcs;
1645 +diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
1646 +index 26e8cfad22b8e..4d5ba9778885d 100644
1647 +--- a/net/bluetooth/smp.c
1648 ++++ b/net/bluetooth/smp.c
1649 +@@ -2685,6 +2685,15 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
1650 + if (skb->len < sizeof(*key))
1651 + return SMP_INVALID_PARAMS;
1652 +
1653 ++ /* Check if remote and local public keys are the same and debug key is
1654 ++ * not in use.
1655 ++ */
1656 ++ if (!test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags) &&
1657 ++ !crypto_memneq(key, smp->local_pk, 64)) {
1658 ++ bt_dev_err(hdev, "Remote and local public keys are identical");
1659 ++ return SMP_UNSPECIFIED;
1660 ++ }
1661 ++
1662 + memcpy(smp->remote_pk, key, 64);
1663 +
1664 + if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) {
1665 +diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
1666 +index b0a904cdb932d..e6b4ca469b2aa 100644
1667 +--- a/sound/firewire/Kconfig
1668 ++++ b/sound/firewire/Kconfig
1669 +@@ -38,7 +38,7 @@ config SND_OXFW
1670 + * Mackie(Loud) Onyx 1640i (former model)
1671 + * Mackie(Loud) Onyx Satellite
1672 + * Mackie(Loud) Tapco Link.Firewire
1673 +- * Mackie(Loud) d.2 pro/d.4 pro
1674 ++ * Mackie(Loud) d.4 pro
1675 + * Mackie(Loud) U.420/U.420d
1676 + * TASCAM FireOne
1677 + * Stanton Controllers & Systems 1 Deck/Mixer
1678 +@@ -84,7 +84,7 @@ config SND_BEBOB
1679 + * PreSonus FIREBOX/FIREPOD/FP10/Inspire1394
1680 + * BridgeCo RDAudio1/Audio5
1681 + * Mackie Onyx 1220/1620/1640 (FireWire I/O Card)
1682 +- * Mackie d.2 (FireWire Option)
1683 ++ * Mackie d.2 (FireWire Option) and d.2 Pro
1684 + * Stanton FinalScratch 2 (ScratchAmp)
1685 + * Tascam IF-FW/DM
1686 + * Behringer XENIX UFX 1204/1604
1687 +diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
1688 +index e50e28f77e74e..07e58dcad4afc 100644
1689 +--- a/sound/firewire/amdtp-stream.c
1690 ++++ b/sound/firewire/amdtp-stream.c
1691 +@@ -617,18 +617,24 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
1692 + unsigned int *syt, unsigned int index)
1693 + {
1694 + const __be32 *cip_header;
1695 ++ unsigned int cip_header_size;
1696 + int err;
1697 +
1698 + *payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT;
1699 +- if (*payload_length > s->ctx_data.tx.ctx_header_size +
1700 +- s->ctx_data.tx.max_ctx_payload_length) {
1701 ++
1702 ++ if (!(s->flags & CIP_NO_HEADER))
1703 ++ cip_header_size = 8;
1704 ++ else
1705 ++ cip_header_size = 0;
1706 ++
1707 ++ if (*payload_length > cip_header_size + s->ctx_data.tx.max_ctx_payload_length) {
1708 + dev_err(&s->unit->device,
1709 + "Detect jumbo payload: %04x %04x\n",
1710 +- *payload_length, s->ctx_data.tx.max_ctx_payload_length);
1711 ++ *payload_length, cip_header_size + s->ctx_data.tx.max_ctx_payload_length);
1712 + return -EIO;
1713 + }
1714 +
1715 +- if (!(s->flags & CIP_NO_HEADER)) {
1716 ++ if (cip_header_size > 0) {
1717 + cip_header = ctx_header + 2;
1718 + err = check_cip_header(s, cip_header, *payload_length,
1719 + data_blocks, data_block_counter, syt);
1720 +@@ -932,23 +938,22 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed)
1721 + s->ctx_data.rx.last_syt_offset = TICKS_PER_CYCLE;
1722 + }
1723 +
1724 +- /* initialize packet buffer */
1725 ++ // initialize packet buffer.
1726 ++ max_ctx_payload_size = amdtp_stream_get_max_payload(s);
1727 + if (s->direction == AMDTP_IN_STREAM) {
1728 + dir = DMA_FROM_DEVICE;
1729 + type = FW_ISO_CONTEXT_RECEIVE;
1730 +- if (!(s->flags & CIP_NO_HEADER))
1731 ++ if (!(s->flags & CIP_NO_HEADER)) {
1732 ++ max_ctx_payload_size -= 8;
1733 + ctx_header_size = IR_CTX_HEADER_SIZE_CIP;
1734 +- else
1735 ++ } else {
1736 + ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP;
1737 +-
1738 +- max_ctx_payload_size = amdtp_stream_get_max_payload(s) -
1739 +- ctx_header_size;
1740 ++ }
1741 + } else {
1742 + dir = DMA_TO_DEVICE;
1743 + type = FW_ISO_CONTEXT_TRANSMIT;
1744 + ctx_header_size = 0; // No effect for IT context.
1745 +
1746 +- max_ctx_payload_size = amdtp_stream_get_max_payload(s);
1747 + if (!(s->flags & CIP_NO_HEADER))
1748 + max_ctx_payload_size -= IT_PKT_HEADER_SIZE_CIP;
1749 + }
1750 +diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
1751 +index 976d8cb9a34f0..441c58283b47e 100644
1752 +--- a/sound/firewire/bebob/bebob.c
1753 ++++ b/sound/firewire/bebob/bebob.c
1754 +@@ -387,7 +387,7 @@ static const struct ieee1394_device_id bebob_id_table[] = {
1755 + SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010049, &spec_normal),
1756 + /* Mackie, Onyx 1220/1620/1640 (Firewire I/O Card) */
1757 + SND_BEBOB_DEV_ENTRY(VEN_MACKIE2, 0x00010065, &spec_normal),
1758 +- /* Mackie, d.2 (Firewire Option) */
1759 ++ // Mackie, d.2 (Firewire option card) and d.2 Pro (the card is built-in).
1760 + SND_BEBOB_DEV_ENTRY(VEN_MACKIE1, 0x00010067, &spec_normal),
1761 + /* Stanton, ScratchAmp */
1762 + SND_BEBOB_DEV_ENTRY(VEN_STANTON, 0x00000001, &spec_normal),
1763 +diff --git a/sound/firewire/dice/dice-alesis.c b/sound/firewire/dice/dice-alesis.c
1764 +index f5b325263b674..39a4ef8c85430 100644
1765 +--- a/sound/firewire/dice/dice-alesis.c
1766 ++++ b/sound/firewire/dice/dice-alesis.c
1767 +@@ -16,7 +16,7 @@ alesis_io14_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = {
1768 + static const unsigned int
1769 + alesis_io26_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = {
1770 + {10, 10, 4}, /* Tx0 = Analog + S/PDIF. */
1771 +- {16, 8, 0}, /* Tx1 = ADAT1 + ADAT2. */
1772 ++ {16, 4, 0}, /* Tx1 = ADAT1 + ADAT2 (available at low rate). */
1773 + };
1774 +
1775 + int snd_dice_detect_alesis_formats(struct snd_dice *dice)
1776 +diff --git a/sound/firewire/dice/dice-tcelectronic.c b/sound/firewire/dice/dice-tcelectronic.c
1777 +index a8875d24ba2aa..43a3bcb15b3d1 100644
1778 +--- a/sound/firewire/dice/dice-tcelectronic.c
1779 ++++ b/sound/firewire/dice/dice-tcelectronic.c
1780 +@@ -38,8 +38,8 @@ static const struct dice_tc_spec konnekt_24d = {
1781 + };
1782 +
1783 + static const struct dice_tc_spec konnekt_live = {
1784 +- .tx_pcm_chs = {{16, 16, 16}, {0, 0, 0} },
1785 +- .rx_pcm_chs = {{16, 16, 16}, {0, 0, 0} },
1786 ++ .tx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
1787 ++ .rx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
1788 + .has_midi = true,
1789 + };
1790 +
1791 +diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
1792 +index fb6df3fc018ed..6184a7c8f2b34 100644
1793 +--- a/sound/firewire/oxfw/oxfw.c
1794 ++++ b/sound/firewire/oxfw/oxfw.c
1795 +@@ -350,7 +350,6 @@ static const struct ieee1394_device_id oxfw_id_table[] = {
1796 + * Onyx-i series (former models): 0x081216
1797 + * Mackie Onyx Satellite: 0x00200f
1798 + * Tapco LINK.firewire 4x6: 0x000460
1799 +- * d.2 pro: Unknown
1800 + * d.4 pro: Unknown
1801 + * U.420: Unknown
1802 + * U.420d: Unknown
1803 +diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
1804 +index d67eae3988bd7..6f1fc87896765 100644
1805 +--- a/sound/isa/sb/sb8.c
1806 ++++ b/sound/isa/sb/sb8.c
1807 +@@ -96,10 +96,6 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
1808 +
1809 + /* block the 0x388 port to avoid PnP conflicts */
1810 + acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
1811 +- if (!acard->fm_res) {
1812 +- err = -EBUSY;
1813 +- goto _err;
1814 +- }
1815 +
1816 + if (port[dev] != SNDRV_AUTO_PORT) {
1817 + if ((err = snd_sbdsp_create(card, port[dev], irq[dev],
1818 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
1819 +index b7297a22438af..d02c49e1686b6 100644
1820 +--- a/sound/pci/hda/patch_realtek.c
1821 ++++ b/sound/pci/hda/patch_realtek.c
1822 +@@ -385,7 +385,6 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
1823 + case 0x10ec0282:
1824 + case 0x10ec0283:
1825 + case 0x10ec0286:
1826 +- case 0x10ec0287:
1827 + case 0x10ec0288:
1828 + case 0x10ec0285:
1829 + case 0x10ec0298:
1830 +@@ -396,6 +395,10 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
1831 + case 0x10ec0275:
1832 + alc_update_coef_idx(codec, 0xe, 0, 1<<0);
1833 + break;
1834 ++ case 0x10ec0287:
1835 ++ alc_update_coef_idx(codec, 0x10, 1<<9, 0);
1836 ++ alc_write_coef_idx(codec, 0x8, 0x4ab7);
1837 ++ break;
1838 + case 0x10ec0293:
1839 + alc_update_coef_idx(codec, 0xa, 1<<13, 0);
1840 + break;
1841 +@@ -5605,6 +5608,18 @@ static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
1842 + spec->gen.preferred_dacs = preferred_pairs;
1843 + }
1844 +
1845 ++static void alc295_fixup_asus_dacs(struct hda_codec *codec,
1846 ++ const struct hda_fixup *fix, int action)
1847 ++{
1848 ++ static const hda_nid_t preferred_pairs[] = {
1849 ++ 0x17, 0x02, 0x21, 0x03, 0
1850 ++ };
1851 ++ struct alc_spec *spec = codec->spec;
1852 ++
1853 ++ if (action == HDA_FIXUP_ACT_PRE_PROBE)
1854 ++ spec->gen.preferred_dacs = preferred_pairs;
1855 ++}
1856 ++
1857 + static void alc_shutup_dell_xps13(struct hda_codec *codec)
1858 + {
1859 + struct alc_spec *spec = codec->spec;
1860 +@@ -6120,6 +6135,35 @@ static void alc294_fixup_gx502_hp(struct hda_codec *codec,
1861 + }
1862 + }
1863 +
1864 ++static void alc294_gu502_toggle_output(struct hda_codec *codec,
1865 ++ struct hda_jack_callback *cb)
1866 ++{
1867 ++ /* Windows sets 0x10 to 0x8420 for Node 0x20 which is
1868 ++ * responsible from changes between speakers and headphones
1869 ++ */
1870 ++ if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
1871 ++ alc_write_coef_idx(codec, 0x10, 0x8420);
1872 ++ else
1873 ++ alc_write_coef_idx(codec, 0x10, 0x0a20);
1874 ++}
1875 ++
1876 ++static void alc294_fixup_gu502_hp(struct hda_codec *codec,
1877 ++ const struct hda_fixup *fix, int action)
1878 ++{
1879 ++ if (!is_jack_detectable(codec, 0x21))
1880 ++ return;
1881 ++
1882 ++ switch (action) {
1883 ++ case HDA_FIXUP_ACT_PRE_PROBE:
1884 ++ snd_hda_jack_detect_enable_callback(codec, 0x21,
1885 ++ alc294_gu502_toggle_output);
1886 ++ break;
1887 ++ case HDA_FIXUP_ACT_INIT:
1888 ++ alc294_gu502_toggle_output(codec, NULL);
1889 ++ break;
1890 ++ }
1891 ++}
1892 ++
1893 + static void alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
1894 + const struct hda_fixup *fix, int action)
1895 + {
1896 +@@ -6316,6 +6360,9 @@ enum {
1897 + ALC294_FIXUP_ASUS_GX502_HP,
1898 + ALC294_FIXUP_ASUS_GX502_PINS,
1899 + ALC294_FIXUP_ASUS_GX502_VERBS,
1900 ++ ALC294_FIXUP_ASUS_GU502_HP,
1901 ++ ALC294_FIXUP_ASUS_GU502_PINS,
1902 ++ ALC294_FIXUP_ASUS_GU502_VERBS,
1903 + ALC285_FIXUP_HP_GPIO_LED,
1904 + ALC285_FIXUP_HP_MUTE_LED,
1905 + ALC236_FIXUP_HP_MUTE_LED,
1906 +@@ -6342,6 +6389,9 @@ enum {
1907 + ALC274_FIXUP_HP_HEADSET_MIC,
1908 + ALC256_FIXUP_ASUS_HPE,
1909 + ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
1910 ++ ALC295_FIXUP_ASUS_DACS,
1911 ++ ALC295_FIXUP_HP_OMEN,
1912 ++ ALC285_FIXUP_HP_SPECTRE_X360,
1913 + };
1914 +
1915 + static const struct hda_fixup alc269_fixups[] = {
1916 +@@ -7540,6 +7590,35 @@ static const struct hda_fixup alc269_fixups[] = {
1917 + .type = HDA_FIXUP_FUNC,
1918 + .v.func = alc294_fixup_gx502_hp,
1919 + },
1920 ++ [ALC294_FIXUP_ASUS_GU502_PINS] = {
1921 ++ .type = HDA_FIXUP_PINS,
1922 ++ .v.pins = (const struct hda_pintbl[]) {
1923 ++ { 0x19, 0x01a11050 }, /* rear HP mic */
1924 ++ { 0x1a, 0x01a11830 }, /* rear external mic */
1925 ++ { 0x21, 0x012110f0 }, /* rear HP out */
1926 ++ { }
1927 ++ },
1928 ++ .chained = true,
1929 ++ .chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
1930 ++ },
1931 ++ [ALC294_FIXUP_ASUS_GU502_VERBS] = {
1932 ++ .type = HDA_FIXUP_VERBS,
1933 ++ .v.verbs = (const struct hda_verb[]) {
1934 ++ /* set 0x15 to HP-OUT ctrl */
1935 ++ { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1936 ++ /* unmute the 0x15 amp */
1937 ++ { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
1938 ++ /* set 0x1b to HP-OUT */
1939 ++ { 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1940 ++ { }
1941 ++ },
1942 ++ .chained = true,
1943 ++ .chain_id = ALC294_FIXUP_ASUS_GU502_HP
1944 ++ },
1945 ++ [ALC294_FIXUP_ASUS_GU502_HP] = {
1946 ++ .type = HDA_FIXUP_FUNC,
1947 ++ .v.func = alc294_fixup_gu502_hp,
1948 ++ },
1949 + [ALC294_FIXUP_ASUS_COEF_1B] = {
1950 + .type = HDA_FIXUP_VERBS,
1951 + .v.verbs = (const struct hda_verb[]) {
1952 +@@ -7778,6 +7857,39 @@ static const struct hda_fixup alc269_fixups[] = {
1953 + .chained = true,
1954 + .chain_id = ALC269_FIXUP_THINKPAD_ACPI
1955 + },
1956 ++ [ALC295_FIXUP_ASUS_DACS] = {
1957 ++ .type = HDA_FIXUP_FUNC,
1958 ++ .v.func = alc295_fixup_asus_dacs,
1959 ++ },
1960 ++ [ALC295_FIXUP_HP_OMEN] = {
1961 ++ .type = HDA_FIXUP_PINS,
1962 ++ .v.pins = (const struct hda_pintbl[]) {
1963 ++ { 0x12, 0xb7a60130 },
1964 ++ { 0x13, 0x40000000 },
1965 ++ { 0x14, 0x411111f0 },
1966 ++ { 0x16, 0x411111f0 },
1967 ++ { 0x17, 0x90170110 },
1968 ++ { 0x18, 0x411111f0 },
1969 ++ { 0x19, 0x02a11030 },
1970 ++ { 0x1a, 0x411111f0 },
1971 ++ { 0x1b, 0x04a19030 },
1972 ++ { 0x1d, 0x40600001 },
1973 ++ { 0x1e, 0x411111f0 },
1974 ++ { 0x21, 0x03211020 },
1975 ++ {}
1976 ++ },
1977 ++ .chained = true,
1978 ++ .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
1979 ++ },
1980 ++ [ALC285_FIXUP_HP_SPECTRE_X360] = {
1981 ++ .type = HDA_FIXUP_PINS,
1982 ++ .v.pins = (const struct hda_pintbl[]) {
1983 ++ { 0x14, 0x90170110 }, /* enable top speaker */
1984 ++ {}
1985 ++ },
1986 ++ .chained = true,
1987 ++ .chain_id = ALC285_FIXUP_SPEAKER2_TO_DAC1,
1988 ++ },
1989 + };
1990 +
1991 + static const struct snd_pci_quirk alc269_fixup_tbl[] = {
1992 +@@ -7928,7 +8040,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
1993 + SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
1994 + SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1995 + SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1996 ++ SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
1997 + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1998 ++ SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
1999 + SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
2000 + SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
2001 + SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
2002 +@@ -7954,6 +8068,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2003 + SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
2004 + SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
2005 + SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
2006 ++ SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
2007 + SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
2008 + SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
2009 + SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
2010 +@@ -7971,6 +8086,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2011 + SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
2012 + SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
2013 + SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
2014 ++ SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
2015 + SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
2016 + SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
2017 + SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
2018 +@@ -8027,12 +8143,19 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2019 + SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2020 + SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2021 + SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2022 ++ SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2023 + SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2024 ++ SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2025 ++ SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2026 + SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2027 + SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2028 + SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2029 + SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2030 + SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2031 ++ SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2032 ++ SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2033 ++ SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2034 ++ SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2035 + SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2036 + SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2037 + SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2038 +@@ -8050,9 +8173,17 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2039 + SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2040 + SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2041 + SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2042 ++ SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2043 + SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2044 + SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2045 + SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL53RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2046 ++ SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL5XNU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2047 ++ SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2048 ++ SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2049 ++ SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2050 ++ SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2051 ++ SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2052 ++ SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
2053 + SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
2054 + SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
2055 + SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
2056 +@@ -8315,6 +8446,8 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
2057 + {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
2058 + {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
2059 + {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
2060 ++ {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
2061 ++ {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
2062 + {}
2063 + };
2064 + #define ALC225_STANDARD_PINS \
2065 +diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
2066 +index 6ff94d8ad86e5..2a73fc4fd019f 100644
2067 +--- a/sound/pci/intel8x0.c
2068 ++++ b/sound/pci/intel8x0.c
2069 +@@ -354,6 +354,7 @@ struct ichdev {
2070 + unsigned int ali_slot; /* ALI DMA slot */
2071 + struct ac97_pcm *pcm;
2072 + int pcm_open_flag;
2073 ++ unsigned int prepared:1;
2074 + unsigned int suspended: 1;
2075 + };
2076 +
2077 +@@ -714,6 +715,9 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
2078 + int status, civ, i, step;
2079 + int ack = 0;
2080 +
2081 ++ if (!ichdev->prepared || ichdev->suspended)
2082 ++ return;
2083 ++
2084 + spin_lock_irqsave(&chip->reg_lock, flags);
2085 + status = igetbyte(chip, port + ichdev->roff_sr);
2086 + civ = igetbyte(chip, port + ICH_REG_OFF_CIV);
2087 +@@ -907,6 +911,7 @@ static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream,
2088 + if (ichdev->pcm_open_flag) {
2089 + snd_ac97_pcm_close(ichdev->pcm);
2090 + ichdev->pcm_open_flag = 0;
2091 ++ ichdev->prepared = 0;
2092 + }
2093 + err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params),
2094 + params_channels(hw_params),
2095 +@@ -928,6 +933,7 @@ static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream)
2096 + if (ichdev->pcm_open_flag) {
2097 + snd_ac97_pcm_close(ichdev->pcm);
2098 + ichdev->pcm_open_flag = 0;
2099 ++ ichdev->prepared = 0;
2100 + }
2101 + return snd_pcm_lib_free_pages(substream);
2102 + }
2103 +@@ -1002,6 +1008,7 @@ static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream)
2104 + ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
2105 + }
2106 + snd_intel8x0_setup_periods(chip, ichdev);
2107 ++ ichdev->prepared = 1;
2108 + return 0;
2109 + }
2110 +
2111 +diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
2112 +index 0caf53f5764cb..1e38cdda2af69 100644
2113 +--- a/sound/usb/line6/driver.c
2114 ++++ b/sound/usb/line6/driver.c
2115 +@@ -690,6 +690,10 @@ static int line6_init_cap_control(struct usb_line6 *line6)
2116 + line6->buffer_message = kmalloc(LINE6_MIDI_MESSAGE_MAXLEN, GFP_KERNEL);
2117 + if (!line6->buffer_message)
2118 + return -ENOMEM;
2119 ++
2120 ++ ret = line6_init_midi(line6);
2121 ++ if (ret < 0)
2122 ++ return ret;
2123 + } else {
2124 + ret = line6_hwdep_init(line6);
2125 + if (ret < 0)
2126 +diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c
2127 +index ee4c9d220fdf7..b667bb8ad938a 100644
2128 +--- a/sound/usb/line6/pod.c
2129 ++++ b/sound/usb/line6/pod.c
2130 +@@ -376,11 +376,6 @@ static int pod_init(struct usb_line6 *line6,
2131 + if (err < 0)
2132 + return err;
2133 +
2134 +- /* initialize MIDI subsystem: */
2135 +- err = line6_init_midi(line6);
2136 +- if (err < 0)
2137 +- return err;
2138 +-
2139 + /* initialize PCM subsystem: */
2140 + err = line6_init_pcm(line6, &pod_pcm_properties);
2141 + if (err < 0)
2142 +diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c
2143 +index ed158f04de80f..c2245aa93b08f 100644
2144 +--- a/sound/usb/line6/variax.c
2145 ++++ b/sound/usb/line6/variax.c
2146 +@@ -159,7 +159,6 @@ static int variax_init(struct usb_line6 *line6,
2147 + const struct usb_device_id *id)
2148 + {
2149 + struct usb_line6_variax *variax = line6_to_variax(line6);
2150 +- int err;
2151 +
2152 + line6->process_message = line6_variax_process_message;
2153 + line6->disconnect = line6_variax_disconnect;
2154 +@@ -172,11 +171,6 @@ static int variax_init(struct usb_line6 *line6,
2155 + if (variax->buffer_activate == NULL)
2156 + return -ENOMEM;
2157 +
2158 +- /* initialize MIDI subsystem: */
2159 +- err = line6_init_midi(&variax->line6);
2160 +- if (err < 0)
2161 +- return err;
2162 +-
2163 + /* initiate startup procedure: */
2164 + schedule_delayed_work(&line6->startup_work,
2165 + msecs_to_jiffies(VARIAX_STARTUP_DELAY1));
2166 +diff --git a/sound/usb/midi.c b/sound/usb/midi.c
2167 +index c205a26ef5092..33e9a7f6246f7 100644
2168 +--- a/sound/usb/midi.c
2169 ++++ b/sound/usb/midi.c
2170 +@@ -1889,8 +1889,12 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi *umidi,
2171 + ms_ep = find_usb_ms_endpoint_descriptor(hostep);
2172 + if (!ms_ep)
2173 + continue;
2174 ++ if (ms_ep->bLength <= sizeof(*ms_ep))
2175 ++ continue;
2176 + if (ms_ep->bNumEmbMIDIJack > 0x10)
2177 + continue;
2178 ++ if (ms_ep->bLength < sizeof(*ms_ep) + ms_ep->bNumEmbMIDIJack)
2179 ++ continue;
2180 + if (usb_endpoint_dir_out(ep)) {
2181 + if (endpoints[epidx].out_ep) {
2182 + if (++epidx >= MIDI_MAX_ENDPOINTS) {