Magellan Linux

Contents of /trunk/kernel-alx/patches-4.9/0320-4.9.221-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3595 - (show annotations) (download)
Thu Aug 13 10:21:36 2020 UTC (3 years, 8 months ago) by niro
File size: 76222 byte(s)
linux-221
1 diff --git a/Makefile b/Makefile
2 index e7866bc2d817..b919a66788b5 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 220
9 +SUBLEVEL = 221
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
14 index 3a4014870a91..44c6ea0b86a6 100644
15 --- a/arch/arm/mach-imx/Makefile
16 +++ b/arch/arm/mach-imx/Makefile
17 @@ -86,8 +86,10 @@ AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
18 obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o
19 obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o
20 endif
21 +ifeq ($(CONFIG_ARM_CPU_SUSPEND),y)
22 AFLAGS_resume-imx6.o :=-Wa,-march=armv7-a
23 obj-$(CONFIG_SOC_IMX6) += resume-imx6.o
24 +endif
25 obj-$(CONFIG_SOC_IMX6) += pm-imx6.o
26
27 obj-$(CONFIG_SOC_IMX1) += mach-imx1.o
28 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
29 index 2ad59d8553a5..b62886f10dc1 100644
30 --- a/arch/x86/kvm/vmx.c
31 +++ b/arch/x86/kvm/vmx.c
32 @@ -5785,7 +5785,7 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
33 */
34 static void kvm_machine_check(void)
35 {
36 -#if defined(CONFIG_X86_MCE) && defined(CONFIG_X86_64)
37 +#if defined(CONFIG_X86_MCE)
38 struct pt_regs regs = {
39 .cs = 3, /* Fake ring 3 no matter what the guest ran on */
40 .flags = X86_EFLAGS_IF,
41 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
42 index d9dabd0c31fc..eb5734112cb4 100644
43 --- a/arch/x86/net/bpf_jit_comp.c
44 +++ b/arch/x86/net/bpf_jit_comp.c
45 @@ -150,6 +150,19 @@ static bool is_ereg(u32 reg)
46 BIT(BPF_REG_AX));
47 }
48
49 +/*
50 + * is_ereg_8l() == true if BPF register 'reg' is mapped to access x86-64
51 + * lower 8-bit registers dil,sil,bpl,spl,r8b..r15b, which need extra byte
52 + * of encoding. al,cl,dl,bl have simpler encoding.
53 + */
54 +static bool is_ereg_8l(u32 reg)
55 +{
56 + return is_ereg(reg) ||
57 + (1 << reg) & (BIT(BPF_REG_1) |
58 + BIT(BPF_REG_2) |
59 + BIT(BPF_REG_FP));
60 +}
61 +
62 /* add modifiers if 'reg' maps to x64 registers r8..r15 */
63 static u8 add_1mod(u8 byte, u32 reg)
64 {
65 @@ -771,9 +784,8 @@ st: if (is_imm8(insn->off))
66 /* STX: *(u8*)(dst_reg + off) = src_reg */
67 case BPF_STX | BPF_MEM | BPF_B:
68 /* emit 'mov byte ptr [rax + off], al' */
69 - if (is_ereg(dst_reg) || is_ereg(src_reg) ||
70 - /* have to add extra byte for x86 SIL, DIL regs */
71 - src_reg == BPF_REG_1 || src_reg == BPF_REG_2)
72 + if (is_ereg(dst_reg) || is_ereg_8l(src_reg))
73 + /* Add extra byte for eregs or SIL,DIL,BPL in src_reg */
74 EMIT2(add_2mod(0x40, dst_reg, src_reg), 0x88);
75 else
76 EMIT1(0x88);
77 diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
78 index f9aa47ec7af7..b78f6a347f29 100644
79 --- a/drivers/char/tpm/tpm_tis_core.c
80 +++ b/drivers/char/tpm/tpm_tis_core.c
81 @@ -329,6 +329,9 @@ static void disable_interrupts(struct tpm_chip *chip)
82 u32 intmask;
83 int rc;
84
85 + if (priv->irq == 0)
86 + return;
87 +
88 rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask);
89 if (rc < 0)
90 intmask = 0;
91 @@ -786,9 +789,12 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
92 if (irq) {
93 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
94 irq);
95 - if (!(chip->flags & TPM_CHIP_FLAG_IRQ))
96 + if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
97 dev_err(&chip->dev, FW_BUG
98 "TPM interrupt not working, polling instead\n");
99 +
100 + disable_interrupts(chip);
101 + }
102 } else {
103 tpm_tis_probe_irq(chip, intmask);
104 }
105 diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
106 index 78212ba16eeb..34839b539207 100644
107 --- a/drivers/crypto/mxs-dcp.c
108 +++ b/drivers/crypto/mxs-dcp.c
109 @@ -37,11 +37,11 @@
110 * Null hashes to align with hw behavior on imx6sl and ull
111 * these are flipped for consistency with hw output
112 */
113 -const uint8_t sha1_null_hash[] =
114 +static const uint8_t sha1_null_hash[] =
115 "\x09\x07\xd8\xaf\x90\x18\x60\x95\xef\xbf"
116 "\x55\x32\x0d\x4b\x6b\x5e\xee\xa3\x39\xda";
117
118 -const uint8_t sha256_null_hash[] =
119 +static const uint8_t sha256_null_hash[] =
120 "\x55\xb8\x52\x78\x1b\x99\x95\xa4"
121 "\x4c\x93\x9b\x64\xe4\x41\xae\x27"
122 "\x24\xb9\x6f\x99\xc8\xf4\xfb\x9a"
123 diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
124 index 569e8c45a59a..983ce7965c7f 100644
125 --- a/drivers/gpu/drm/msm/msm_gem.c
126 +++ b/drivers/gpu/drm/msm/msm_gem.c
127 @@ -58,7 +58,7 @@ static void sync_for_device(struct msm_gem_object *msm_obj)
128 {
129 struct device *dev = msm_obj->base.dev->dev;
130
131 - if (get_dma_ops(dev)) {
132 + if (get_dma_ops(dev) && IS_ENABLED(CONFIG_ARM64)) {
133 dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
134 msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
135 } else {
136 @@ -71,7 +71,7 @@ static void sync_for_cpu(struct msm_gem_object *msm_obj)
137 {
138 struct device *dev = msm_obj->base.dev->dev;
139
140 - if (get_dma_ops(dev)) {
141 + if (get_dma_ops(dev) && IS_ENABLED(CONFIG_ARM64)) {
142 dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
143 msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
144 } else {
145 diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
146 index 0f1f6421845f..85435e110ecd 100644
147 --- a/drivers/hwmon/jc42.c
148 +++ b/drivers/hwmon/jc42.c
149 @@ -508,7 +508,7 @@ static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id)
150 }
151 data->config = config;
152
153 - hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
154 + hwmon_dev = devm_hwmon_device_register_with_info(dev, "jc42",
155 data, &jc42_chip_info,
156 NULL);
157 return PTR_ERR_OR_ZERO(hwmon_dev);
158 diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
159 index 143894a315d9..640ead6a2157 100644
160 --- a/drivers/iio/adc/xilinx-xadc-core.c
161 +++ b/drivers/iio/adc/xilinx-xadc-core.c
162 @@ -660,7 +660,7 @@ static int xadc_trigger_set_state(struct iio_trigger *trigger, bool state)
163
164 spin_lock_irqsave(&xadc->lock, flags);
165 xadc_read_reg(xadc, XADC_AXI_REG_IPIER, &val);
166 - xadc_write_reg(xadc, XADC_AXI_REG_IPISR, val & XADC_AXI_INT_EOS);
167 + xadc_write_reg(xadc, XADC_AXI_REG_IPISR, XADC_AXI_INT_EOS);
168 if (state)
169 val |= XADC_AXI_INT_EOS;
170 else
171 @@ -709,13 +709,14 @@ static int xadc_power_adc_b(struct xadc *xadc, unsigned int seq_mode)
172 {
173 uint16_t val;
174
175 + /* Powerdown the ADC-B when it is not needed. */
176 switch (seq_mode) {
177 case XADC_CONF1_SEQ_SIMULTANEOUS:
178 case XADC_CONF1_SEQ_INDEPENDENT:
179 - val = XADC_CONF2_PD_ADC_B;
180 + val = 0;
181 break;
182 default:
183 - val = 0;
184 + val = XADC_CONF2_PD_ADC_B;
185 break;
186 }
187
188 @@ -784,6 +785,16 @@ static int xadc_preenable(struct iio_dev *indio_dev)
189 if (ret)
190 goto err;
191
192 + /*
193 + * In simultaneous mode the upper and lower aux channels are samples at
194 + * the same time. In this mode the upper 8 bits in the sequencer
195 + * register are don't care and the lower 8 bits control two channels
196 + * each. As such we must set the bit if either the channel in the lower
197 + * group or the upper group is enabled.
198 + */
199 + if (seq_mode == XADC_CONF1_SEQ_SIMULTANEOUS)
200 + scan_mask = ((scan_mask >> 8) | scan_mask) & 0xff0000;
201 +
202 ret = xadc_write_adc_reg(xadc, XADC_REG_SEQ(1), scan_mask >> 16);
203 if (ret)
204 goto err;
205 diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
206 index 8725e406a9eb..00ba09fa6f16 100644
207 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
208 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
209 @@ -1879,7 +1879,11 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
210 continue;
211 }
212
213 - if (time_after(jiffies, timeo) && !chip_ready(map, adr))
214 + /*
215 + * We check "time_after" and "!chip_good" before checking "chip_good" to avoid
216 + * the failure due to scheduling.
217 + */
218 + if (time_after(jiffies, timeo) && !chip_good(map, adr, datum))
219 break;
220
221 if (chip_good(map, adr, datum)) {
222 diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
223 index 81044000ce75..85c44bfba55a 100644
224 --- a/drivers/net/dsa/b53/b53_regs.h
225 +++ b/drivers/net/dsa/b53/b53_regs.h
226 @@ -261,7 +261,7 @@
227 *
228 * BCM5325 and BCM5365 share most definitions below
229 */
230 -#define B53_ARLTBL_MAC_VID_ENTRY(n) (0x10 * (n))
231 +#define B53_ARLTBL_MAC_VID_ENTRY(n) ((0x10 * (n)) + 0x10)
232 #define ARLTBL_MAC_MASK 0xffffffffffffULL
233 #define ARLTBL_VID_S 48
234 #define ARLTBL_VID_MASK_25 0xff
235 @@ -273,7 +273,7 @@
236 #define ARLTBL_VALID_25 BIT(63)
237
238 /* ARL Table Data Entry N Registers (32 bit) */
239 -#define B53_ARLTBL_DATA_ENTRY(n) ((0x10 * (n)) + 0x08)
240 +#define B53_ARLTBL_DATA_ENTRY(n) ((0x10 * (n)) + 0x18)
241 #define ARLTBL_DATA_PORT_ID_MASK 0x1ff
242 #define ARLTBL_TC(tc) ((3 & tc) << 11)
243 #define ARLTBL_AGE BIT(14)
244 diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
245 index b4b435276a18..62bc2af9cde7 100644
246 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
247 +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
248 @@ -3400,7 +3400,7 @@ int t4_phy_fw_ver(struct adapter *adap, int *phy_fw_ver)
249 FW_PARAMS_PARAM_Z_V(FW_PARAMS_PARAM_DEV_PHYFW_VERSION));
250 ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1,
251 &param, &val);
252 - if (ret < 0)
253 + if (ret)
254 return ret;
255 *phy_fw_ver = val;
256 return 0;
257 diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
258 index da8bf327a3e9..df2ee65a33e3 100644
259 --- a/drivers/net/macsec.c
260 +++ b/drivers/net/macsec.c
261 @@ -3209,11 +3209,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
262 struct nlattr *tb[], struct nlattr *data[])
263 {
264 struct macsec_dev *macsec = macsec_priv(dev);
265 + rx_handler_func_t *rx_handler;
266 + u8 icv_len = DEFAULT_ICV_LEN;
267 struct net_device *real_dev;
268 - int err;
269 + int err, mtu;
270 sci_t sci;
271 - u8 icv_len = DEFAULT_ICV_LEN;
272 - rx_handler_func_t *rx_handler;
273
274 if (!tb[IFLA_LINK])
275 return -EINVAL;
276 @@ -3229,7 +3229,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
277
278 if (data && data[IFLA_MACSEC_ICV_LEN])
279 icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
280 - dev->mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
281 + mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
282 + if (mtu < 0)
283 + dev->mtu = 0;
284 + else
285 + dev->mtu = mtu;
286
287 rx_handler = rtnl_dereference(real_dev->rx_handler);
288 if (rx_handler && rx_handler != macsec_handle_frame)
289 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
290 index 294881621430..4f582ce929f2 100644
291 --- a/drivers/net/macvlan.c
292 +++ b/drivers/net/macvlan.c
293 @@ -1607,7 +1607,7 @@ static int macvlan_device_event(struct notifier_block *unused,
294 struct macvlan_dev,
295 list);
296
297 - if (macvlan_sync_address(vlan->dev, dev->dev_addr))
298 + if (vlan && macvlan_sync_address(vlan->dev, dev->dev_addr))
299 return NOTIFY_BAD;
300
301 break;
302 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
303 index d0c18e3557f1..cea6d2eabe7e 100644
304 --- a/drivers/net/team/team.c
305 +++ b/drivers/net/team/team.c
306 @@ -480,6 +480,9 @@ static const struct team_mode *team_mode_get(const char *kind)
307 struct team_mode_item *mitem;
308 const struct team_mode *mode = NULL;
309
310 + if (!try_module_get(THIS_MODULE))
311 + return NULL;
312 +
313 spin_lock(&mode_list_lock);
314 mitem = __find_mode(kind);
315 if (!mitem) {
316 @@ -495,6 +498,7 @@ static const struct team_mode *team_mode_get(const char *kind)
317 }
318
319 spin_unlock(&mode_list_lock);
320 + module_put(THIS_MODULE);
321 return mode;
322 }
323
324 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
325 index b12fe65d07f8..4a5fde58974a 100644
326 --- a/drivers/pci/pcie/aspm.c
327 +++ b/drivers/pci/pcie/aspm.c
328 @@ -57,6 +57,7 @@ struct pcie_link_state {
329 u32 clkpm_capable:1; /* Clock PM capable? */
330 u32 clkpm_enabled:1; /* Current Clock PM state */
331 u32 clkpm_default:1; /* Default Clock PM state by BIOS */
332 + u32 clkpm_disable:1; /* Clock PM disabled */
333
334 /* Exit latencies */
335 struct aspm_latency latency_up; /* Upstream direction exit latency */
336 @@ -138,8 +139,11 @@ static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable)
337
338 static void pcie_set_clkpm(struct pcie_link_state *link, int enable)
339 {
340 - /* Don't enable Clock PM if the link is not Clock PM capable */
341 - if (!link->clkpm_capable)
342 + /*
343 + * Don't enable Clock PM if the link is not Clock PM capable
344 + * or Clock PM is disabled
345 + */
346 + if (!link->clkpm_capable || link->clkpm_disable)
347 enable = 0;
348 /* Need nothing if the specified equals to current state */
349 if (link->clkpm_enabled == enable)
350 @@ -169,7 +173,8 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
351 }
352 link->clkpm_enabled = enabled;
353 link->clkpm_default = enabled;
354 - link->clkpm_capable = (blacklist) ? 0 : capable;
355 + link->clkpm_capable = capable;
356 + link->clkpm_disable = blacklist ? 1 : 0;
357 }
358
359 static bool pcie_retrain_link(struct pcie_link_state *link)
360 @@ -773,10 +778,9 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
361 link->aspm_disable |= ASPM_STATE_L1;
362 pcie_config_aspm_link(link, policy_to_aspm_state(link));
363
364 - if (state & PCIE_LINK_STATE_CLKPM) {
365 - link->clkpm_capable = 0;
366 - pcie_set_clkpm(link, 0);
367 - }
368 + if (state & PCIE_LINK_STATE_CLKPM)
369 + link->clkpm_disable = 1;
370 + pcie_set_clkpm(link, policy_to_clkpm_state(link));
371 mutex_unlock(&aspm_lock);
372 if (sem)
373 up_read(&pci_bus_sem);
374 diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
375 index c5dbf16d810b..aeed963f827b 100644
376 --- a/drivers/pwm/pwm-bcm2835.c
377 +++ b/drivers/pwm/pwm-bcm2835.c
378 @@ -166,6 +166,7 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
379
380 pc->chip.dev = &pdev->dev;
381 pc->chip.ops = &bcm2835_pwm_ops;
382 + pc->chip.base = -1;
383 pc->chip.npwm = 2;
384
385 platform_set_drvdata(pdev, pc);
386 diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
387 index 0fcf94ffad32..c298bec25a90 100644
388 --- a/drivers/pwm/pwm-rcar.c
389 +++ b/drivers/pwm/pwm-rcar.c
390 @@ -236,24 +236,28 @@ static int rcar_pwm_probe(struct platform_device *pdev)
391 rcar_pwm->chip.base = -1;
392 rcar_pwm->chip.npwm = 1;
393
394 + pm_runtime_enable(&pdev->dev);
395 +
396 ret = pwmchip_add(&rcar_pwm->chip);
397 if (ret < 0) {
398 dev_err(&pdev->dev, "failed to register PWM chip: %d\n", ret);
399 + pm_runtime_disable(&pdev->dev);
400 return ret;
401 }
402
403 - pm_runtime_enable(&pdev->dev);
404 -
405 return 0;
406 }
407
408 static int rcar_pwm_remove(struct platform_device *pdev)
409 {
410 struct rcar_pwm_chip *rcar_pwm = platform_get_drvdata(pdev);
411 + int ret;
412 +
413 + ret = pwmchip_remove(&rcar_pwm->chip);
414
415 pm_runtime_disable(&pdev->dev);
416
417 - return pwmchip_remove(&rcar_pwm->chip);
418 + return ret;
419 }
420
421 static const struct of_device_id rcar_pwm_of_table[] = {
422 diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
423 index 075c1a764ba2..6247a956cc08 100644
424 --- a/drivers/pwm/pwm-renesas-tpu.c
425 +++ b/drivers/pwm/pwm-renesas-tpu.c
426 @@ -423,16 +423,17 @@ static int tpu_probe(struct platform_device *pdev)
427 tpu->chip.base = -1;
428 tpu->chip.npwm = TPU_CHANNEL_MAX;
429
430 + pm_runtime_enable(&pdev->dev);
431 +
432 ret = pwmchip_add(&tpu->chip);
433 if (ret < 0) {
434 dev_err(&pdev->dev, "failed to register PWM chip\n");
435 + pm_runtime_disable(&pdev->dev);
436 return ret;
437 }
438
439 dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);
440
441 - pm_runtime_enable(&pdev->dev);
442 -
443 return 0;
444 }
445
446 @@ -442,12 +443,10 @@ static int tpu_remove(struct platform_device *pdev)
447 int ret;
448
449 ret = pwmchip_remove(&tpu->chip);
450 - if (ret)
451 - return ret;
452
453 pm_runtime_disable(&pdev->dev);
454
455 - return 0;
456 + return ret;
457 }
458
459 #ifdef CONFIG_OF
460 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
461 index b99780574044..0254f034149b 100644
462 --- a/drivers/remoteproc/remoteproc_core.c
463 +++ b/drivers/remoteproc/remoteproc_core.c
464 @@ -284,7 +284,7 @@ void rproc_free_vring(struct rproc_vring *rvring)
465 {
466 int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
467 struct rproc *rproc = rvring->rvdev->rproc;
468 - int idx = rvring->rvdev->vring - rvring;
469 + int idx = rvring - rvring->rvdev->vring;
470 struct fw_rsc_vdev *rsc;
471
472 dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
473 diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
474 index 6a58bc8f46e2..1e97d1a03467 100644
475 --- a/drivers/s390/cio/device.c
476 +++ b/drivers/s390/cio/device.c
477 @@ -868,8 +868,10 @@ static void io_subchannel_register(struct ccw_device *cdev)
478 * Now we know this subchannel will stay, we can throw
479 * our delayed uevent.
480 */
481 - dev_set_uevent_suppress(&sch->dev, 0);
482 - kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
483 + if (dev_get_uevent_suppress(&sch->dev)) {
484 + dev_set_uevent_suppress(&sch->dev, 0);
485 + kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
486 + }
487 /* make it known to the system */
488 ret = ccw_device_add(cdev);
489 if (ret) {
490 @@ -1077,8 +1079,11 @@ static int io_subchannel_probe(struct subchannel *sch)
491 * Throw the delayed uevent for the subchannel, register
492 * the ccw_device and exit.
493 */
494 - dev_set_uevent_suppress(&sch->dev, 0);
495 - kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
496 + if (dev_get_uevent_suppress(&sch->dev)) {
497 + /* should always be the case for the console */
498 + dev_set_uevent_suppress(&sch->dev, 0);
499 + kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
500 + }
501 cdev = sch_get_cdev(sch);
502 rc = ccw_device_add(cdev);
503 if (rc) {
504 diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
505 index cbe808e83f47..1c34dc335549 100644
506 --- a/drivers/scsi/lpfc/lpfc_sli.c
507 +++ b/drivers/scsi/lpfc/lpfc_sli.c
508 @@ -2210,6 +2210,8 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
509 !pmb->u.mb.mbxStatus) {
510 rpi = pmb->u.mb.un.varWords[0];
511 vpi = pmb->u.mb.un.varRegLogin.vpi;
512 + if (phba->sli_rev == LPFC_SLI_REV4)
513 + vpi -= phba->sli4_hba.max_cfg_param.vpi_base;
514 lpfc_unreg_login(phba, vpi, rpi, pmb);
515 pmb->vport = vport;
516 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
517 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
518 index fff9c4d0f7c8..42b97f119623 100644
519 --- a/drivers/scsi/scsi_transport_iscsi.c
520 +++ b/drivers/scsi/scsi_transport_iscsi.c
521 @@ -2016,7 +2016,7 @@ static void __iscsi_unbind_session(struct work_struct *work)
522 if (session->target_id == ISCSI_MAX_TARGET) {
523 spin_unlock_irqrestore(&session->lock, flags);
524 mutex_unlock(&ihost->mutex);
525 - return;
526 + goto unbind_session_exit;
527 }
528
529 target_id = session->target_id;
530 @@ -2028,6 +2028,8 @@ static void __iscsi_unbind_session(struct work_struct *work)
531 ida_simple_remove(&iscsi_sess_ida, target_id);
532
533 scsi_remove_target(&session->dev);
534 +
535 +unbind_session_exit:
536 iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION);
537 ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n");
538 }
539 diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
540 index 7458df4b6854..3090c8dea2a6 100644
541 --- a/drivers/staging/comedi/comedi_fops.c
542 +++ b/drivers/staging/comedi/comedi_fops.c
543 @@ -2592,8 +2592,10 @@ static int comedi_open(struct inode *inode, struct file *file)
544 }
545
546 cfp = kzalloc(sizeof(*cfp), GFP_KERNEL);
547 - if (!cfp)
548 + if (!cfp) {
549 + comedi_dev_put(dev);
550 return -ENOMEM;
551 + }
552
553 cfp->dev = dev;
554
555 diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c
556 index 0be77cc40a79..8ab36b351195 100644
557 --- a/drivers/staging/comedi/drivers/dt2815.c
558 +++ b/drivers/staging/comedi/drivers/dt2815.c
559 @@ -101,6 +101,7 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
560 int ret;
561
562 for (i = 0; i < insn->n; i++) {
563 + /* FIXME: lo bit 0 chooses voltage output or current output */
564 lo = ((data[i] & 0x0f) << 4) | (chan << 1) | 0x01;
565 hi = (data[i] & 0xff0) >> 4;
566
567 @@ -114,6 +115,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
568 if (ret)
569 return ret;
570
571 + outb(hi, dev->iobase + DT2815_DATA);
572 +
573 devpriv->ao_readback[chan] = data[i];
574 }
575 return i;
576 diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
577 index b554e881e67f..f7ed09119893 100644
578 --- a/drivers/staging/vt6656/int.c
579 +++ b/drivers/staging/vt6656/int.c
580 @@ -153,7 +153,8 @@ void vnt_int_process_data(struct vnt_private *priv)
581 priv->wake_up_count =
582 priv->hw->conf.listen_interval;
583
584 - --priv->wake_up_count;
585 + if (priv->wake_up_count)
586 + --priv->wake_up_count;
587
588 /* Turn on wake up to listen next beacon */
589 if (priv->wake_up_count == 1)
590 diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
591 index b93773af2031..860a0ddd7a16 100644
592 --- a/drivers/staging/vt6656/main_usb.c
593 +++ b/drivers/staging/vt6656/main_usb.c
594 @@ -755,12 +755,15 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
595 vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL,
596 TFTCTL_TSFCNTREN);
597
598 - vnt_adjust_tsf(priv, conf->beacon_rate->hw_value,
599 - conf->sync_tsf, priv->current_tsf);
600 -
601 vnt_mac_set_beacon_interval(priv, conf->beacon_int);
602
603 vnt_reset_next_tbtt(priv, conf->beacon_int);
604 +
605 + vnt_adjust_tsf(priv, conf->beacon_rate->hw_value,
606 + conf->sync_tsf, priv->current_tsf);
607 +
608 + vnt_update_next_tbtt(priv,
609 + conf->sync_tsf, conf->beacon_int);
610 } else {
611 vnt_clear_current_tsf(priv);
612
613 diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
614 index 6e75095af681..2ecb2f7042a1 100644
615 --- a/drivers/target/target_core_fabric_lib.c
616 +++ b/drivers/target/target_core_fabric_lib.c
617 @@ -75,7 +75,7 @@ static int fc_get_pr_transport_id(
618 * encoded TransportID.
619 */
620 ptr = &se_nacl->initiatorname[0];
621 - for (i = 0; i < 24; ) {
622 + for (i = 0; i < 23; ) {
623 if (!strncmp(&ptr[i], ":", 1)) {
624 i++;
625 continue;
626 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
627 index ce864875330e..f8964247c4c3 100644
628 --- a/drivers/tty/hvc/hvc_console.c
629 +++ b/drivers/tty/hvc/hvc_console.c
630 @@ -289,10 +289,6 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
631 vtermnos[index] = vtermno;
632 cons_ops[index] = ops;
633
634 - /* reserve all indices up to and including this index */
635 - if (last_hvc < index)
636 - last_hvc = index;
637 -
638 /* check if we need to re-register the kernel console */
639 hvc_check_console(index);
640
641 @@ -896,13 +892,22 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
642 cons_ops[i] == hp->ops)
643 break;
644
645 - /* no matching slot, just use a counter */
646 - if (i >= MAX_NR_HVC_CONSOLES)
647 - i = ++last_hvc;
648 + if (i >= MAX_NR_HVC_CONSOLES) {
649 +
650 + /* find 'empty' slot for console */
651 + for (i = 0; i < MAX_NR_HVC_CONSOLES && vtermnos[i] != -1; i++) {
652 + }
653 +
654 + /* no matching slot, just use a counter */
655 + if (i == MAX_NR_HVC_CONSOLES)
656 + i = ++last_hvc + MAX_NR_HVC_CONSOLES;
657 + }
658
659 hp->index = i;
660 - cons_ops[i] = ops;
661 - vtermnos[i] = vtermno;
662 + if (i < MAX_NR_HVC_CONSOLES) {
663 + cons_ops[i] = ops;
664 + vtermnos[i] = vtermno;
665 + }
666
667 list_add_tail(&(hp->next), &hvc_structs);
668 spin_unlock(&hvc_structs_lock);
669 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
670 index 447d791bde22..1e8f6096260f 100644
671 --- a/drivers/tty/rocket.c
672 +++ b/drivers/tty/rocket.c
673 @@ -645,18 +645,21 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
674 tty_port_init(&info->port);
675 info->port.ops = &rocket_port_ops;
676 info->flags &= ~ROCKET_MODE_MASK;
677 - switch (pc104[board][line]) {
678 - case 422:
679 - info->flags |= ROCKET_MODE_RS422;
680 - break;
681 - case 485:
682 - info->flags |= ROCKET_MODE_RS485;
683 - break;
684 - case 232:
685 - default:
686 + if (board < ARRAY_SIZE(pc104) && line < ARRAY_SIZE(pc104_1))
687 + switch (pc104[board][line]) {
688 + case 422:
689 + info->flags |= ROCKET_MODE_RS422;
690 + break;
691 + case 485:
692 + info->flags |= ROCKET_MODE_RS485;
693 + break;
694 + case 232:
695 + default:
696 + info->flags |= ROCKET_MODE_RS232;
697 + break;
698 + }
699 + else
700 info->flags |= ROCKET_MODE_RS232;
701 - break;
702 - }
703
704 info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR;
705 if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) {
706 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
707 index c958cf42a1bb..238dfe0f6e80 100644
708 --- a/drivers/usb/core/hub.c
709 +++ b/drivers/usb/core/hub.c
710 @@ -1191,6 +1191,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
711 #ifdef CONFIG_PM
712 udev->reset_resume = 1;
713 #endif
714 + /* Don't set the change_bits when the device
715 + * was powered off.
716 + */
717 + if (test_bit(port1, hub->power_bits))
718 + set_bit(port1, hub->change_bits);
719
720 } else {
721 /* The power session is gone; tell hub_wq */
722 @@ -2991,6 +2996,15 @@ static int check_port_resume_type(struct usb_device *udev,
723 if (portchange & USB_PORT_STAT_C_ENABLE)
724 usb_clear_port_feature(hub->hdev, port1,
725 USB_PORT_FEAT_C_ENABLE);
726 +
727 + /*
728 + * Whatever made this reset-resume necessary may have
729 + * turned on the port1 bit in hub->change_bits. But after
730 + * a successful reset-resume we want the bit to be clear;
731 + * if it was on it would indicate that something happened
732 + * following the reset-resume.
733 + */
734 + clear_bit(port1, hub->change_bits);
735 }
736
737 return status;
738 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
739 index d6075d45e10a..2e541a029657 100644
740 --- a/drivers/usb/core/message.c
741 +++ b/drivers/usb/core/message.c
742 @@ -585,12 +585,13 @@ void usb_sg_cancel(struct usb_sg_request *io)
743 int i, retval;
744
745 spin_lock_irqsave(&io->lock, flags);
746 - if (io->status) {
747 + if (io->status || io->count == 0) {
748 spin_unlock_irqrestore(&io->lock, flags);
749 return;
750 }
751 /* shut everything down */
752 io->status = -ECONNRESET;
753 + io->count++; /* Keep the request alive until we're done */
754 spin_unlock_irqrestore(&io->lock, flags);
755
756 for (i = io->entries - 1; i >= 0; --i) {
757 @@ -604,6 +605,12 @@ void usb_sg_cancel(struct usb_sg_request *io)
758 dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
759 __func__, retval);
760 }
761 +
762 + spin_lock_irqsave(&io->lock, flags);
763 + io->count--;
764 + if (!io->count)
765 + complete(&io->complete);
766 + spin_unlock_irqrestore(&io->lock, flags);
767 }
768 EXPORT_SYMBOL_GPL(usb_sg_cancel);
769
770 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
771 index 6c4bb47922ac..27d05f0134de 100644
772 --- a/drivers/usb/core/quirks.c
773 +++ b/drivers/usb/core/quirks.c
774 @@ -272,6 +272,10 @@ static const struct usb_device_id usb_quirk_list[] = {
775 /* Corsair K70 LUX */
776 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
777
778 + /* Corsair K70 RGB RAPDIFIRE */
779 + { USB_DEVICE(0x1b1c, 0x1b38), .driver_info = USB_QUIRK_DELAY_INIT |
780 + USB_QUIRK_DELAY_CTRL_MSG },
781 +
782 /* MIDI keyboard WORLDE MINI */
783 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
784 USB_QUIRK_CONFIG_INTF_STRINGS },
785 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
786 index 223b28cbf3c8..bea11be98526 100644
787 --- a/drivers/usb/gadget/function/f_fs.c
788 +++ b/drivers/usb/gadget/function/f_fs.c
789 @@ -1701,6 +1701,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
790 ffs->state = FFS_READ_DESCRIPTORS;
791 ffs->setup_state = FFS_NO_SETUP;
792 ffs->flags = 0;
793 +
794 + ffs->ms_os_descs_ext_prop_count = 0;
795 + ffs->ms_os_descs_ext_prop_name_len = 0;
796 + ffs->ms_os_descs_ext_prop_data_len = 0;
797 }
798
799
800 diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
801 index ccaa74ab6c0e..303735c7990c 100644
802 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
803 +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
804 @@ -546,7 +546,7 @@ static void bdc_req_complete(struct bdc_ep *ep, struct bdc_req *req,
805 {
806 struct bdc *bdc = ep->bdc;
807
808 - if (req == NULL || &req->queue == NULL || &req->usb_req == NULL)
809 + if (req == NULL)
810 return;
811
812 dev_dbg(bdc->dev, "%s ep:%s status:%d\n", __func__, ep->name, status);
813 diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
814 index b7a4ba020893..895e8c0288cf 100644
815 --- a/drivers/usb/misc/sisusbvga/sisusb.c
816 +++ b/drivers/usb/misc/sisusbvga/sisusb.c
817 @@ -1200,18 +1200,18 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
818 /* High level: Gfx (indexed) register access */
819
820 #ifdef INCL_SISUSB_CON
821 -int sisusb_setreg(struct sisusb_usb_data *sisusb, int port, u8 data)
822 +int sisusb_setreg(struct sisusb_usb_data *sisusb, u32 port, u8 data)
823 {
824 return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, port, data);
825 }
826
827 -int sisusb_getreg(struct sisusb_usb_data *sisusb, int port, u8 *data)
828 +int sisusb_getreg(struct sisusb_usb_data *sisusb, u32 port, u8 *data)
829 {
830 return sisusb_read_memio_byte(sisusb, SISUSB_TYPE_IO, port, data);
831 }
832 #endif
833
834 -int sisusb_setidxreg(struct sisusb_usb_data *sisusb, int port,
835 +int sisusb_setidxreg(struct sisusb_usb_data *sisusb, u32 port,
836 u8 index, u8 data)
837 {
838 int ret;
839 @@ -1221,7 +1221,7 @@ int sisusb_setidxreg(struct sisusb_usb_data *sisusb, int port,
840 return ret;
841 }
842
843 -int sisusb_getidxreg(struct sisusb_usb_data *sisusb, int port,
844 +int sisusb_getidxreg(struct sisusb_usb_data *sisusb, u32 port,
845 u8 index, u8 *data)
846 {
847 int ret;
848 @@ -1231,7 +1231,7 @@ int sisusb_getidxreg(struct sisusb_usb_data *sisusb, int port,
849 return ret;
850 }
851
852 -int sisusb_setidxregandor(struct sisusb_usb_data *sisusb, int port, u8 idx,
853 +int sisusb_setidxregandor(struct sisusb_usb_data *sisusb, u32 port, u8 idx,
854 u8 myand, u8 myor)
855 {
856 int ret;
857 @@ -1246,7 +1246,7 @@ int sisusb_setidxregandor(struct sisusb_usb_data *sisusb, int port, u8 idx,
858 }
859
860 static int sisusb_setidxregmask(struct sisusb_usb_data *sisusb,
861 - int port, u8 idx, u8 data, u8 mask)
862 + u32 port, u8 idx, u8 data, u8 mask)
863 {
864 int ret;
865 u8 tmp;
866 @@ -1259,13 +1259,13 @@ static int sisusb_setidxregmask(struct sisusb_usb_data *sisusb,
867 return ret;
868 }
869
870 -int sisusb_setidxregor(struct sisusb_usb_data *sisusb, int port,
871 +int sisusb_setidxregor(struct sisusb_usb_data *sisusb, u32 port,
872 u8 index, u8 myor)
873 {
874 return sisusb_setidxregandor(sisusb, port, index, 0xff, myor);
875 }
876
877 -int sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port,
878 +int sisusb_setidxregand(struct sisusb_usb_data *sisusb, u32 port,
879 u8 idx, u8 myand)
880 {
881 return sisusb_setidxregandor(sisusb, port, idx, myand, 0x00);
882 @@ -2796,8 +2796,8 @@ static loff_t sisusb_lseek(struct file *file, loff_t offset, int orig)
883 static int sisusb_handle_command(struct sisusb_usb_data *sisusb,
884 struct sisusb_command *y, unsigned long arg)
885 {
886 - int retval, port, length;
887 - u32 address;
888 + int retval, length;
889 + u32 port, address;
890
891 /* All our commands require the device
892 * to be initialized.
893 diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.h b/drivers/usb/misc/sisusbvga/sisusb_init.h
894 index e79a616f0d26..f7182257f7e1 100644
895 --- a/drivers/usb/misc/sisusbvga/sisusb_init.h
896 +++ b/drivers/usb/misc/sisusbvga/sisusb_init.h
897 @@ -811,17 +811,17 @@ static const struct SiS_VCLKData SiSUSB_VCLKData[] = {
898 int SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
899 int SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo);
900
901 -extern int sisusb_setreg(struct sisusb_usb_data *sisusb, int port, u8 data);
902 -extern int sisusb_getreg(struct sisusb_usb_data *sisusb, int port, u8 * data);
903 -extern int sisusb_setidxreg(struct sisusb_usb_data *sisusb, int port,
904 +extern int sisusb_setreg(struct sisusb_usb_data *sisusb, u32 port, u8 data);
905 +extern int sisusb_getreg(struct sisusb_usb_data *sisusb, u32 port, u8 * data);
906 +extern int sisusb_setidxreg(struct sisusb_usb_data *sisusb, u32 port,
907 u8 index, u8 data);
908 -extern int sisusb_getidxreg(struct sisusb_usb_data *sisusb, int port,
909 +extern int sisusb_getidxreg(struct sisusb_usb_data *sisusb, u32 port,
910 u8 index, u8 * data);
911 -extern int sisusb_setidxregandor(struct sisusb_usb_data *sisusb, int port,
912 +extern int sisusb_setidxregandor(struct sisusb_usb_data *sisusb, u32 port,
913 u8 idx, u8 myand, u8 myor);
914 -extern int sisusb_setidxregor(struct sisusb_usb_data *sisusb, int port,
915 +extern int sisusb_setidxregor(struct sisusb_usb_data *sisusb, u32 port,
916 u8 index, u8 myor);
917 -extern int sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port,
918 +extern int sisusb_setidxregand(struct sisusb_usb_data *sisusb, u32 port,
919 u8 idx, u8 myand);
920
921 void sisusb_delete(struct kref *kref);
922 diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
923 index d022b5ff4cd0..bb7556952a18 100644
924 --- a/drivers/usb/storage/uas.c
925 +++ b/drivers/usb/storage/uas.c
926 @@ -82,6 +82,19 @@ static void uas_free_streams(struct uas_dev_info *devinfo);
927 static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
928 int status);
929
930 +/*
931 + * This driver needs its own workqueue, as we need to control memory allocation.
932 + *
933 + * In the course of error handling and power management uas_wait_for_pending_cmnds()
934 + * needs to flush pending work items. In these contexts we cannot allocate memory
935 + * by doing block IO as we would deadlock. For the same reason we cannot wait
936 + * for anything allocating memory not heeding these constraints.
937 + *
938 + * So we have to control all work items that can be on the workqueue we flush.
939 + * Hence we cannot share a queue and need our own.
940 + */
941 +static struct workqueue_struct *workqueue;
942 +
943 static void uas_do_work(struct work_struct *work)
944 {
945 struct uas_dev_info *devinfo =
946 @@ -110,7 +123,7 @@ static void uas_do_work(struct work_struct *work)
947 if (!err)
948 cmdinfo->state &= ~IS_IN_WORK_LIST;
949 else
950 - schedule_work(&devinfo->work);
951 + queue_work(workqueue, &devinfo->work);
952 }
953 out:
954 spin_unlock_irqrestore(&devinfo->lock, flags);
955 @@ -135,7 +148,7 @@ static void uas_add_work(struct uas_cmd_info *cmdinfo)
956
957 lockdep_assert_held(&devinfo->lock);
958 cmdinfo->state |= IS_IN_WORK_LIST;
959 - schedule_work(&devinfo->work);
960 + queue_work(workqueue, &devinfo->work);
961 }
962
963 static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
964 @@ -191,6 +204,9 @@ static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
965 struct uas_cmd_info *ci = (void *)&cmnd->SCp;
966 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
967
968 + if (status == -ENODEV) /* too late */
969 + return;
970 +
971 scmd_printk(KERN_INFO, cmnd,
972 "%s %d uas-tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
973 prefix, status, cmdinfo->uas_tag,
974 @@ -1233,7 +1249,31 @@ static struct usb_driver uas_driver = {
975 .id_table = uas_usb_ids,
976 };
977
978 -module_usb_driver(uas_driver);
979 +static int __init uas_init(void)
980 +{
981 + int rv;
982 +
983 + workqueue = alloc_workqueue("uas", WQ_MEM_RECLAIM, 0);
984 + if (!workqueue)
985 + return -ENOMEM;
986 +
987 + rv = usb_register(&uas_driver);
988 + if (rv) {
989 + destroy_workqueue(workqueue);
990 + return -ENOMEM;
991 + }
992 +
993 + return 0;
994 +}
995 +
996 +static void __exit uas_exit(void)
997 +{
998 + usb_deregister(&uas_driver);
999 + destroy_workqueue(workqueue);
1000 +}
1001 +
1002 +module_init(uas_init);
1003 +module_exit(uas_exit);
1004
1005 MODULE_LICENSE("GPL");
1006 MODULE_AUTHOR(
1007 diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1008 index a52ae34fb1c3..46079468df42 100644
1009 --- a/drivers/usb/storage/unusual_devs.h
1010 +++ b/drivers/usb/storage/unusual_devs.h
1011 @@ -2342,6 +2342,13 @@ UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000,
1012 USB_SC_DEVICE,USB_PR_DEVICE,NULL,
1013 US_FL_MAX_SECTORS_64 ),
1014
1015 +/* Reported by Cyril Roelandt <tipecaml@gmail.com> */
1016 +UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114,
1017 + "JMicron",
1018 + "USB to ATA/ATAPI Bridge",
1019 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1020 + US_FL_BROKEN_FUA ),
1021 +
1022 /* Reported by Andrey Rahmatullin <wrar@altlinux.org> */
1023 UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
1024 "iRiver",
1025 diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
1026 index 977fe74e5abe..9e17d933ea94 100644
1027 --- a/drivers/watchdog/watchdog_dev.c
1028 +++ b/drivers/watchdog/watchdog_dev.c
1029 @@ -237,6 +237,7 @@ static int watchdog_start(struct watchdog_device *wdd)
1030 if (err == 0) {
1031 set_bit(WDOG_ACTIVE, &wdd->status);
1032 wd_data->last_keepalive = started_at;
1033 + wd_data->last_hw_keepalive = started_at;
1034 watchdog_update_worker(wdd);
1035 }
1036
1037 diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
1038 index 056da6ee1a35..df27cefb2fa3 100644
1039 --- a/drivers/xen/xenbus/xenbus_client.c
1040 +++ b/drivers/xen/xenbus/xenbus_client.c
1041 @@ -469,7 +469,14 @@ EXPORT_SYMBOL_GPL(xenbus_free_evtchn);
1042 int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs,
1043 unsigned int nr_grefs, void **vaddr)
1044 {
1045 - return ring_ops->map(dev, gnt_refs, nr_grefs, vaddr);
1046 + int err;
1047 +
1048 + err = ring_ops->map(dev, gnt_refs, nr_grefs, vaddr);
1049 + /* Some hypervisors are buggy and can return 1. */
1050 + if (err > 0)
1051 + err = GNTST_general_error;
1052 +
1053 + return err;
1054 }
1055 EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
1056
1057 diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
1058 index f5d9835264aa..617e9ae67f50 100644
1059 --- a/fs/ceph/caps.c
1060 +++ b/fs/ceph/caps.c
1061 @@ -1764,8 +1764,12 @@ retry_locked:
1062 }
1063
1064 /* want more caps from mds? */
1065 - if (want & ~(cap->mds_wanted | cap->issued))
1066 - goto ack;
1067 + if (want & ~cap->mds_wanted) {
1068 + if (want & ~(cap->mds_wanted | cap->issued))
1069 + goto ack;
1070 + if (!__cap_is_valid(cap))
1071 + goto ack;
1072 + }
1073
1074 /* things we might delay */
1075 if ((cap->issued & ~retain) == 0 &&
1076 diff --git a/fs/ceph/export.c b/fs/ceph/export.c
1077 index 1780218a48f0..f8e1f31e4643 100644
1078 --- a/fs/ceph/export.c
1079 +++ b/fs/ceph/export.c
1080 @@ -157,6 +157,11 @@ static struct dentry *__get_parent(struct super_block *sb,
1081
1082 req->r_num_caps = 1;
1083 err = ceph_mdsc_do_request(mdsc, NULL, req);
1084 + if (err) {
1085 + ceph_mdsc_put_request(req);
1086 + return ERR_PTR(err);
1087 + }
1088 +
1089 inode = req->r_target_inode;
1090 if (inode)
1091 ihold(inode);
1092 diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
1093 index fdb19543af1e..d31d93ee5e76 100644
1094 --- a/fs/ext4/block_validity.c
1095 +++ b/fs/ext4/block_validity.c
1096 @@ -136,6 +136,49 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
1097 printk(KERN_CONT "\n");
1098 }
1099
1100 +static int ext4_protect_reserved_inode(struct super_block *sb, u32 ino)
1101 +{
1102 + struct inode *inode;
1103 + struct ext4_sb_info *sbi = EXT4_SB(sb);
1104 + struct ext4_map_blocks map;
1105 + u32 i = 0, num;
1106 + int err = 0, n;
1107 +
1108 + if ((ino < EXT4_ROOT_INO) ||
1109 + (ino > le32_to_cpu(sbi->s_es->s_inodes_count)))
1110 + return -EINVAL;
1111 + inode = ext4_iget(sb, ino, EXT4_IGET_SPECIAL);
1112 + if (IS_ERR(inode))
1113 + return PTR_ERR(inode);
1114 + num = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
1115 + while (i < num) {
1116 + map.m_lblk = i;
1117 + map.m_len = num - i;
1118 + n = ext4_map_blocks(NULL, inode, &map, 0);
1119 + if (n < 0) {
1120 + err = n;
1121 + break;
1122 + }
1123 + if (n == 0) {
1124 + i++;
1125 + } else {
1126 + if (!ext4_data_block_valid(sbi, map.m_pblk, n)) {
1127 + ext4_error(sb, "blocks %llu-%llu from inode %u "
1128 + "overlap system zone", map.m_pblk,
1129 + map.m_pblk + map.m_len - 1, ino);
1130 + err = -EFSCORRUPTED;
1131 + break;
1132 + }
1133 + err = add_system_zone(sbi, map.m_pblk, n);
1134 + if (err < 0)
1135 + break;
1136 + i += n;
1137 + }
1138 + }
1139 + iput(inode);
1140 + return err;
1141 +}
1142 +
1143 int ext4_setup_system_zone(struct super_block *sb)
1144 {
1145 ext4_group_t ngroups = ext4_get_groups_count(sb);
1146 @@ -170,6 +213,12 @@ int ext4_setup_system_zone(struct super_block *sb)
1147 if (ret)
1148 return ret;
1149 }
1150 + if (ext4_has_feature_journal(sb) && sbi->s_es->s_journal_inum) {
1151 + ret = ext4_protect_reserved_inode(sb,
1152 + le32_to_cpu(sbi->s_es->s_journal_inum));
1153 + if (ret)
1154 + return ret;
1155 + }
1156
1157 if (test_opt(sb, DEBUG))
1158 debug_print_tree(EXT4_SB(sb));
1159 @@ -226,6 +275,11 @@ int ext4_check_blockref(const char *function, unsigned int line,
1160 __le32 *bref = p;
1161 unsigned int blk;
1162
1163 + if (ext4_has_feature_journal(inode->i_sb) &&
1164 + (inode->i_ino ==
1165 + le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum)))
1166 + return 0;
1167 +
1168 while (bref < p+max) {
1169 blk = le32_to_cpu(*bref++);
1170 if (blk &&
1171 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
1172 index eb0ec5068423..b41ac328c396 100644
1173 --- a/fs/ext4/ext4.h
1174 +++ b/fs/ext4/ext4.h
1175 @@ -2496,8 +2496,19 @@ int do_journal_get_write_access(handle_t *handle,
1176 #define FALL_BACK_TO_NONDELALLOC 1
1177 #define CONVERT_INLINE_DATA 2
1178
1179 -extern struct inode *ext4_iget(struct super_block *, unsigned long);
1180 -extern struct inode *ext4_iget_normal(struct super_block *, unsigned long);
1181 +typedef enum {
1182 + EXT4_IGET_NORMAL = 0,
1183 + EXT4_IGET_SPECIAL = 0x0001, /* OK to iget a system inode */
1184 + EXT4_IGET_HANDLE = 0x0002 /* Inode # is from a handle */
1185 +} ext4_iget_flags;
1186 +
1187 +extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
1188 + ext4_iget_flags flags, const char *function,
1189 + unsigned int line);
1190 +
1191 +#define ext4_iget(sb, ino, flags) \
1192 + __ext4_iget((sb), (ino), (flags), __func__, __LINE__)
1193 +
1194 extern int ext4_write_inode(struct inode *, struct writeback_control *);
1195 extern int ext4_setattr(struct dentry *, struct iattr *);
1196 extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
1197 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
1198 index 999d2a54297d..51c2713a615a 100644
1199 --- a/fs/ext4/extents.c
1200 +++ b/fs/ext4/extents.c
1201 @@ -510,6 +510,30 @@ int ext4_ext_check_inode(struct inode *inode)
1202 return ext4_ext_check(inode, ext_inode_hdr(inode), ext_depth(inode), 0);
1203 }
1204
1205 +static void ext4_cache_extents(struct inode *inode,
1206 + struct ext4_extent_header *eh)
1207 +{
1208 + struct ext4_extent *ex = EXT_FIRST_EXTENT(eh);
1209 + ext4_lblk_t prev = 0;
1210 + int i;
1211 +
1212 + for (i = le16_to_cpu(eh->eh_entries); i > 0; i--, ex++) {
1213 + unsigned int status = EXTENT_STATUS_WRITTEN;
1214 + ext4_lblk_t lblk = le32_to_cpu(ex->ee_block);
1215 + int len = ext4_ext_get_actual_len(ex);
1216 +
1217 + if (prev && (prev != lblk))
1218 + ext4_es_cache_extent(inode, prev, lblk - prev, ~0,
1219 + EXTENT_STATUS_HOLE);
1220 +
1221 + if (ext4_ext_is_unwritten(ex))
1222 + status = EXTENT_STATUS_UNWRITTEN;
1223 + ext4_es_cache_extent(inode, lblk, len,
1224 + ext4_ext_pblock(ex), status);
1225 + prev = lblk + len;
1226 + }
1227 +}
1228 +
1229 static struct buffer_head *
1230 __read_extent_tree_block(const char *function, unsigned int line,
1231 struct inode *inode, ext4_fsblk_t pblk, int depth,
1232 @@ -530,36 +554,21 @@ __read_extent_tree_block(const char *function, unsigned int line,
1233 }
1234 if (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))
1235 return bh;
1236 - err = __ext4_ext_check(function, line, inode,
1237 - ext_block_hdr(bh), depth, pblk);
1238 - if (err)
1239 - goto errout;
1240 + if (!ext4_has_feature_journal(inode->i_sb) ||
1241 + (inode->i_ino !=
1242 + le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) {
1243 + err = __ext4_ext_check(function, line, inode,
1244 + ext_block_hdr(bh), depth, pblk);
1245 + if (err)
1246 + goto errout;
1247 + }
1248 set_buffer_verified(bh);
1249 /*
1250 * If this is a leaf block, cache all of its entries
1251 */
1252 if (!(flags & EXT4_EX_NOCACHE) && depth == 0) {
1253 struct ext4_extent_header *eh = ext_block_hdr(bh);
1254 - struct ext4_extent *ex = EXT_FIRST_EXTENT(eh);
1255 - ext4_lblk_t prev = 0;
1256 - int i;
1257 -
1258 - for (i = le16_to_cpu(eh->eh_entries); i > 0; i--, ex++) {
1259 - unsigned int status = EXTENT_STATUS_WRITTEN;
1260 - ext4_lblk_t lblk = le32_to_cpu(ex->ee_block);
1261 - int len = ext4_ext_get_actual_len(ex);
1262 -
1263 - if (prev && (prev != lblk))
1264 - ext4_es_cache_extent(inode, prev,
1265 - lblk - prev, ~0,
1266 - EXTENT_STATUS_HOLE);
1267 -
1268 - if (ext4_ext_is_unwritten(ex))
1269 - status = EXTENT_STATUS_UNWRITTEN;
1270 - ext4_es_cache_extent(inode, lblk, len,
1271 - ext4_ext_pblock(ex), status);
1272 - prev = lblk + len;
1273 - }
1274 + ext4_cache_extents(inode, eh);
1275 }
1276 return bh;
1277 errout:
1278 @@ -907,6 +916,8 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
1279 path[0].p_bh = NULL;
1280
1281 i = depth;
1282 + if (!(flags & EXT4_EX_NOCACHE) && depth == 0)
1283 + ext4_cache_extents(inode, eh);
1284 /* walk through the tree */
1285 while (i) {
1286 ext_debug("depth %d: num %d, max %d\n",
1287 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
1288 index c5af7bbf906f..2b699b1f42c0 100644
1289 --- a/fs/ext4/ialloc.c
1290 +++ b/fs/ext4/ialloc.c
1291 @@ -1158,7 +1158,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1292 if (!ext4_test_bit(bit, bitmap_bh->b_data))
1293 goto bad_orphan;
1294
1295 - inode = ext4_iget(sb, ino);
1296 + inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
1297 if (IS_ERR(inode)) {
1298 err = PTR_ERR(inode);
1299 ext4_error(sb, "couldn't read orphan inode %lu (err %d)",
1300 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
1301 index 45bcde1969e3..e049dc682e57 100644
1302 --- a/fs/ext4/inode.c
1303 +++ b/fs/ext4/inode.c
1304 @@ -374,6 +374,10 @@ static int __check_block_validity(struct inode *inode, const char *func,
1305 unsigned int line,
1306 struct ext4_map_blocks *map)
1307 {
1308 + if (ext4_has_feature_journal(inode->i_sb) &&
1309 + (inode->i_ino ==
1310 + le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum)))
1311 + return 0;
1312 if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,
1313 map->m_len)) {
1314 ext4_error_inode(inode, func, line, map->m_pblk,
1315 @@ -4474,7 +4478,9 @@ int ext4_get_projid(struct inode *inode, kprojid_t *projid)
1316 return 0;
1317 }
1318
1319 -struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1320 +struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
1321 + ext4_iget_flags flags, const char *function,
1322 + unsigned int line)
1323 {
1324 struct ext4_iloc iloc;
1325 struct ext4_inode *raw_inode;
1326 @@ -4488,6 +4494,18 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1327 gid_t i_gid;
1328 projid_t i_projid;
1329
1330 + if (((flags & EXT4_IGET_NORMAL) &&
1331 + (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)) ||
1332 + (ino < EXT4_ROOT_INO) ||
1333 + (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) {
1334 + if (flags & EXT4_IGET_HANDLE)
1335 + return ERR_PTR(-ESTALE);
1336 + __ext4_error(sb, function, line,
1337 + "inode #%lu: comm %s: iget: illegal inode #",
1338 + ino, current->comm);
1339 + return ERR_PTR(-EFSCORRUPTED);
1340 + }
1341 +
1342 inode = iget_locked(sb, ino);
1343 if (!inode)
1344 return ERR_PTR(-ENOMEM);
1345 @@ -4503,11 +4521,18 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1346 raw_inode = ext4_raw_inode(&iloc);
1347
1348 if ((ino == EXT4_ROOT_INO) && (raw_inode->i_links_count == 0)) {
1349 - EXT4_ERROR_INODE(inode, "root inode unallocated");
1350 + ext4_error_inode(inode, function, line, 0,
1351 + "iget: root inode unallocated");
1352 ret = -EFSCORRUPTED;
1353 goto bad_inode;
1354 }
1355
1356 + if ((flags & EXT4_IGET_HANDLE) &&
1357 + (raw_inode->i_links_count == 0) && (raw_inode->i_mode == 0)) {
1358 + ret = -ESTALE;
1359 + goto bad_inode;
1360 + }
1361 +
1362 if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
1363 ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
1364 if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
1365 @@ -4534,7 +4559,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1366 }
1367
1368 if (!ext4_inode_csum_verify(inode, raw_inode, ei)) {
1369 - EXT4_ERROR_INODE(inode, "checksum invalid");
1370 + ext4_error_inode(inode, function, line, 0,
1371 + "iget: checksum invalid");
1372 ret = -EFSBADCRC;
1373 goto bad_inode;
1374 }
1375 @@ -4590,7 +4616,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1376 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
1377 inode->i_size = ext4_isize(raw_inode);
1378 if ((size = i_size_read(inode)) < 0) {
1379 - EXT4_ERROR_INODE(inode, "bad i_size value: %lld", size);
1380 + ext4_error_inode(inode, function, line, 0,
1381 + "iget: bad i_size value: %lld", size);
1382 ret = -EFSCORRUPTED;
1383 goto bad_inode;
1384 }
1385 @@ -4673,7 +4700,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1386 ret = 0;
1387 if (ei->i_file_acl &&
1388 !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
1389 - EXT4_ERROR_INODE(inode, "bad extended attribute block %llu",
1390 + ext4_error_inode(inode, function, line, 0,
1391 + "iget: bad extended attribute block %llu",
1392 ei->i_file_acl);
1393 ret = -EFSCORRUPTED;
1394 goto bad_inode;
1395 @@ -4728,7 +4756,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
1396 make_bad_inode(inode);
1397 } else {
1398 ret = -EFSCORRUPTED;
1399 - EXT4_ERROR_INODE(inode, "bogus i_mode (%o)", inode->i_mode);
1400 + ext4_error_inode(inode, function, line, 0,
1401 + "iget: bogus i_mode (%o)", inode->i_mode);
1402 goto bad_inode;
1403 }
1404 brelse(iloc.bh);
1405 @@ -4742,13 +4771,6 @@ bad_inode:
1406 return ERR_PTR(ret);
1407 }
1408
1409 -struct inode *ext4_iget_normal(struct super_block *sb, unsigned long ino)
1410 -{
1411 - if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
1412 - return ERR_PTR(-EFSCORRUPTED);
1413 - return ext4_iget(sb, ino);
1414 -}
1415 -
1416 static int ext4_inode_blocks_set(handle_t *handle,
1417 struct ext4_inode *raw_inode,
1418 struct ext4_inode_info *ei)
1419 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
1420 index baa2f6375226..eada4172c4ef 100644
1421 --- a/fs/ext4/ioctl.c
1422 +++ b/fs/ext4/ioctl.c
1423 @@ -104,7 +104,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
1424 if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
1425 return -EPERM;
1426
1427 - inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
1428 + inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO, EXT4_IGET_SPECIAL);
1429 if (IS_ERR(inode_bl))
1430 return PTR_ERR(inode_bl);
1431 ei_bl = EXT4_I(inode_bl);
1432 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
1433 index c18668e3135e..ac13de1a7e42 100644
1434 --- a/fs/ext4/mballoc.c
1435 +++ b/fs/ext4/mballoc.c
1436 @@ -1944,7 +1944,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1437 int free;
1438
1439 free = e4b->bd_info->bb_free;
1440 - BUG_ON(free <= 0);
1441 + if (WARN_ON(free <= 0))
1442 + return;
1443
1444 i = e4b->bd_info->bb_first_free;
1445
1446 @@ -1965,7 +1966,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1447 }
1448
1449 mb_find_extent(e4b, i, ac->ac_g_ex.fe_len, &ex);
1450 - BUG_ON(ex.fe_len <= 0);
1451 + if (WARN_ON(ex.fe_len <= 0))
1452 + break;
1453 if (free < ex.fe_len) {
1454 ext4_grp_locked_error(sb, e4b->bd_group, 0, 0,
1455 "%d free clusters as per "
1456 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
1457 index 339ede11896a..6225ce9f1884 100644
1458 --- a/fs/ext4/namei.c
1459 +++ b/fs/ext4/namei.c
1460 @@ -1626,7 +1626,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1461 dentry);
1462 return ERR_PTR(-EFSCORRUPTED);
1463 }
1464 - inode = ext4_iget_normal(dir->i_sb, ino);
1465 + inode = ext4_iget(dir->i_sb, ino, EXT4_IGET_NORMAL);
1466 if (inode == ERR_PTR(-ESTALE)) {
1467 EXT4_ERROR_INODE(dir,
1468 "deleted inode referenced: %u",
1469 @@ -1675,7 +1675,7 @@ struct dentry *ext4_get_parent(struct dentry *child)
1470 return ERR_PTR(-EFSCORRUPTED);
1471 }
1472
1473 - return d_obtain_alias(ext4_iget_normal(child->d_sb, ino));
1474 + return d_obtain_alias(ext4_iget(child->d_sb, ino, EXT4_IGET_NORMAL));
1475 }
1476
1477 /*
1478 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
1479 index 845d9841c91c..51fa706707a3 100644
1480 --- a/fs/ext4/resize.c
1481 +++ b/fs/ext4/resize.c
1482 @@ -1649,7 +1649,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
1483 "No reserved GDT blocks, can't resize");
1484 return -EPERM;
1485 }
1486 - inode = ext4_iget(sb, EXT4_RESIZE_INO);
1487 + inode = ext4_iget(sb, EXT4_RESIZE_INO, EXT4_IGET_SPECIAL);
1488 if (IS_ERR(inode)) {
1489 ext4_warning(sb, "Error opening resize inode");
1490 return PTR_ERR(inode);
1491 @@ -1977,7 +1977,8 @@ retry:
1492 }
1493
1494 if (!resize_inode)
1495 - resize_inode = ext4_iget(sb, EXT4_RESIZE_INO);
1496 + resize_inode = ext4_iget(sb, EXT4_RESIZE_INO,
1497 + EXT4_IGET_SPECIAL);
1498 if (IS_ERR(resize_inode)) {
1499 ext4_warning(sb, "Error opening resize inode");
1500 return PTR_ERR(resize_inode);
1501 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
1502 index ed0520fe4dad..370e4273042c 100644
1503 --- a/fs/ext4/super.c
1504 +++ b/fs/ext4/super.c
1505 @@ -1049,20 +1049,11 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
1506 {
1507 struct inode *inode;
1508
1509 - if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
1510 - return ERR_PTR(-ESTALE);
1511 - if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
1512 - return ERR_PTR(-ESTALE);
1513 -
1514 - /* iget isn't really right if the inode is currently unallocated!!
1515 - *
1516 - * ext4_read_inode will return a bad_inode if the inode had been
1517 - * deleted, so we should be safe.
1518 - *
1519 + /*
1520 * Currently we don't know the generation for parent directory, so
1521 * a generation of 0 means "accept any"
1522 */
1523 - inode = ext4_iget_normal(sb, ino);
1524 + inode = ext4_iget(sb, ino, EXT4_IGET_HANDLE);
1525 if (IS_ERR(inode))
1526 return ERR_CAST(inode);
1527 if (generation && inode->i_generation != generation) {
1528 @@ -3346,7 +3337,8 @@ int ext4_calculate_overhead(struct super_block *sb)
1529 */
1530 if (sbi->s_journal && !sbi->journal_bdev)
1531 overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
1532 - else if (ext4_has_feature_journal(sb) && !sbi->s_journal) {
1533 + else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
1534 + /* j_inum for internal journal is non-zero */
1535 j_inode = ext4_get_journal_inode(sb, j_inum);
1536 if (j_inode) {
1537 j_blocks = j_inode->i_size >> sb->s_blocksize_bits;
1538 @@ -4195,7 +4187,7 @@ no_journal:
1539 * so we can safely mount the rest of the filesystem now.
1540 */
1541
1542 - root = ext4_iget(sb, EXT4_ROOT_INO);
1543 + root = ext4_iget(sb, EXT4_ROOT_INO, EXT4_IGET_SPECIAL);
1544 if (IS_ERR(root)) {
1545 ext4_msg(sb, KERN_ERR, "get root inode failed");
1546 ret = PTR_ERR(root);
1547 @@ -4447,7 +4439,7 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,
1548 * happen if we iget() an unused inode, as the subsequent iput()
1549 * will try to delete it.
1550 */
1551 - journal_inode = ext4_iget(sb, journal_inum);
1552 + journal_inode = ext4_iget(sb, journal_inum, EXT4_IGET_SPECIAL);
1553 if (IS_ERR(journal_inode)) {
1554 ext4_msg(sb, KERN_ERR, "no journal found");
1555 return NULL;
1556 @@ -5476,7 +5468,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
1557 if (!qf_inums[type])
1558 return -EPERM;
1559
1560 - qf_inode = ext4_iget(sb, qf_inums[type]);
1561 + qf_inode = ext4_iget(sb, qf_inums[type], EXT4_IGET_SPECIAL);
1562 if (IS_ERR(qf_inode)) {
1563 ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]);
1564 return PTR_ERR(qf_inode);
1565 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
1566 index 8016cd059db1..b99225e11712 100644
1567 --- a/fs/fuse/dev.c
1568 +++ b/fs/fuse/dev.c
1569 @@ -132,9 +132,13 @@ static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
1570
1571 static void fuse_drop_waiting(struct fuse_conn *fc)
1572 {
1573 - if (fc->connected) {
1574 - atomic_dec(&fc->num_waiting);
1575 - } else if (atomic_dec_and_test(&fc->num_waiting)) {
1576 + /*
1577 + * lockess check of fc->connected is okay, because atomic_dec_and_test()
1578 + * provides a memory barrier mached with the one in fuse_wait_aborted()
1579 + * to ensure no wake-up is missed.
1580 + */
1581 + if (atomic_dec_and_test(&fc->num_waiting) &&
1582 + !READ_ONCE(fc->connected)) {
1583 /* wake up aborters */
1584 wake_up_all(&fc->blocked_waitq);
1585 }
1586 @@ -2164,6 +2168,8 @@ EXPORT_SYMBOL_GPL(fuse_abort_conn);
1587
1588 void fuse_wait_aborted(struct fuse_conn *fc)
1589 {
1590 + /* matches implicit memory barrier in fuse_drop_waiting() */
1591 + smp_mb();
1592 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0);
1593 }
1594
1595 diff --git a/fs/namespace.c b/fs/namespace.c
1596 index 41f906a6f5d9..3b20c7ff8cc3 100644
1597 --- a/fs/namespace.c
1598 +++ b/fs/namespace.c
1599 @@ -3184,8 +3184,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
1600 /* make certain new is below the root */
1601 if (!is_path_reachable(new_mnt, new.dentry, &root))
1602 goto out4;
1603 - root_mp->m_count++; /* pin it so it won't go away */
1604 lock_mount_hash();
1605 + root_mp->m_count++; /* pin it so it won't go away */
1606 detach_mnt(new_mnt, &parent_path);
1607 detach_mnt(root_mnt, &root_parent);
1608 if (root_mnt->mnt.mnt_flags & MNT_LOCKED) {
1609 diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
1610 index 4509c76716e3..5c9231d5e14a 100644
1611 --- a/fs/nfsd/nfs4state.c
1612 +++ b/fs/nfsd/nfs4state.c
1613 @@ -246,6 +246,8 @@ find_or_allocate_block(struct nfs4_lockowner *lo, struct knfsd_fh *fh,
1614 if (!nbl) {
1615 nbl= kmalloc(sizeof(*nbl), GFP_KERNEL);
1616 if (nbl) {
1617 + INIT_LIST_HEAD(&nbl->nbl_list);
1618 + INIT_LIST_HEAD(&nbl->nbl_lru);
1619 fh_copy_shallow(&nbl->nbl_fh, fh);
1620 locks_init_lock(&nbl->nbl_lock);
1621 nfsd4_init_cb(&nbl->nbl_cb, lo->lo_owner.so_client,
1622 diff --git a/fs/pnode.c b/fs/pnode.c
1623 index d15c63e97ef1..64e9a401d67d 100644
1624 --- a/fs/pnode.c
1625 +++ b/fs/pnode.c
1626 @@ -268,14 +268,13 @@ static int propagate_one(struct mount *m)
1627 if (IS_ERR(child))
1628 return PTR_ERR(child);
1629 child->mnt.mnt_flags &= ~MNT_LOCKED;
1630 + read_seqlock_excl(&mount_lock);
1631 mnt_set_mountpoint(m, mp, child);
1632 + if (m->mnt_master != dest_master)
1633 + SET_MNT_MARK(m->mnt_master);
1634 + read_sequnlock_excl(&mount_lock);
1635 last_dest = m;
1636 last_source = child;
1637 - if (m->mnt_master != dest_master) {
1638 - read_seqlock_excl(&mount_lock);
1639 - SET_MNT_MARK(m->mnt_master);
1640 - read_sequnlock_excl(&mount_lock);
1641 - }
1642 hlist_add_head(&child->mnt_hash, list);
1643 return count_mounts(m->mnt_ns, child);
1644 }
1645 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
1646 index 93d13f4010c1..8e8012769f3e 100644
1647 --- a/fs/proc/vmcore.c
1648 +++ b/fs/proc/vmcore.c
1649 @@ -459,7 +459,7 @@ static int mmap_vmcore(struct file *file, struct vm_area_struct *vma)
1650 tsz = min(elfcorebuf_sz + elfnotes_sz - (size_t)start, size);
1651 kaddr = elfnotes_buf + start - elfcorebuf_sz;
1652 if (remap_vmalloc_range_partial(vma, vma->vm_start + len,
1653 - kaddr, tsz))
1654 + kaddr, 0, tsz))
1655 goto fail;
1656 size -= tsz;
1657 start += tsz;
1658 diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
1659 index 17d3c964a2a2..6b753b969f7b 100644
1660 --- a/fs/xfs/xfs_reflink.c
1661 +++ b/fs/xfs/xfs_reflink.c
1662 @@ -1162,6 +1162,7 @@ xfs_reflink_remap_extent(
1663 uirec.br_startblock = irec->br_startblock + rlen;
1664 uirec.br_startoff = irec->br_startoff + rlen;
1665 uirec.br_blockcount = unmap_len - rlen;
1666 + uirec.br_state = irec->br_state;
1667 unmap_len = rlen;
1668
1669 /* If this isn't a real mapping, we're done. */
1670 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
1671 index ab90a8541aaa..bb4af1bfcaf4 100644
1672 --- a/include/linux/kvm_host.h
1673 +++ b/include/linux/kvm_host.h
1674 @@ -914,7 +914,7 @@ search_memslots(struct kvm_memslots *slots, gfn_t gfn)
1675 start = slot + 1;
1676 }
1677
1678 - if (gfn >= memslots[start].base_gfn &&
1679 + if (start < slots->used_slots && gfn >= memslots[start].base_gfn &&
1680 gfn < memslots[start].base_gfn + memslots[start].npages) {
1681 atomic_set(&slots->lru_slot, start);
1682 return &memslots[start];
1683 diff --git a/include/linux/overflow.h b/include/linux/overflow.h
1684 index c8890ec358a7..d309788f4cd2 100644
1685 --- a/include/linux/overflow.h
1686 +++ b/include/linux/overflow.h
1687 @@ -202,4 +202,35 @@
1688
1689 #endif /* COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW */
1690
1691 +/** check_shl_overflow() - Calculate a left-shifted value and check overflow
1692 + *
1693 + * @a: Value to be shifted
1694 + * @s: How many bits left to shift
1695 + * @d: Pointer to where to store the result
1696 + *
1697 + * Computes *@d = (@a << @s)
1698 + *
1699 + * Returns true if '*d' cannot hold the result or when 'a << s' doesn't
1700 + * make sense. Example conditions:
1701 + * - 'a << s' causes bits to be lost when stored in *d.
1702 + * - 's' is garbage (e.g. negative) or so large that the result of
1703 + * 'a << s' is guaranteed to be 0.
1704 + * - 'a' is negative.
1705 + * - 'a << s' sets the sign bit, if any, in '*d'.
1706 + *
1707 + * '*d' will hold the results of the attempted shift, but is not
1708 + * considered "safe for use" if false is returned.
1709 + */
1710 +#define check_shl_overflow(a, s, d) ({ \
1711 + typeof(a) _a = a; \
1712 + typeof(s) _s = s; \
1713 + typeof(d) _d = d; \
1714 + u64 _a_full = _a; \
1715 + unsigned int _to_shift = \
1716 + _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \
1717 + *_d = (_a_full << _to_shift); \
1718 + (_to_shift != _s || *_d < 0 || _a < 0 || \
1719 + (*_d >> _to_shift) != _a); \
1720 +})
1721 +
1722 #endif /* __LINUX_OVERFLOW_H */
1723 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
1724 index d868a735545b..72c9c75e894f 100644
1725 --- a/include/linux/vmalloc.h
1726 +++ b/include/linux/vmalloc.h
1727 @@ -89,7 +89,7 @@ extern void vunmap(const void *addr);
1728
1729 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
1730 unsigned long uaddr, void *kaddr,
1731 - unsigned long size);
1732 + unsigned long pgoff, unsigned long size);
1733
1734 extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
1735 unsigned long pgoff);
1736 diff --git a/include/net/tcp.h b/include/net/tcp.h
1737 index 0e3a88f808c6..f26f075250b4 100644
1738 --- a/include/net/tcp.h
1739 +++ b/include/net/tcp.h
1740 @@ -51,7 +51,7 @@ extern struct inet_hashinfo tcp_hashinfo;
1741 extern struct percpu_counter tcp_orphan_count;
1742 void tcp_time_wait(struct sock *sk, int state, int timeo);
1743
1744 -#define MAX_TCP_HEADER (128 + MAX_HEADER)
1745 +#define MAX_TCP_HEADER L1_CACHE_ALIGN(128 + MAX_HEADER)
1746 #define MAX_TCP_OPTION_SPACE 40
1747 #define TCP_MIN_SND_MSS 48
1748 #define TCP_MIN_GSO_SIZE (TCP_MIN_SND_MSS - MAX_TCP_OPTION_SPACE)
1749 diff --git a/ipc/util.c b/ipc/util.c
1750 index 798cad18dd87..e65ecf3ccbda 100644
1751 --- a/ipc/util.c
1752 +++ b/ipc/util.c
1753 @@ -751,13 +751,13 @@ static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
1754 total++;
1755 }
1756
1757 + *new_pos = pos + 1;
1758 if (total >= ids->in_use)
1759 return NULL;
1760
1761 for (; pos < IPCMNI; pos++) {
1762 ipc = idr_find(&ids->ipcs_idr, pos);
1763 if (ipc != NULL) {
1764 - *new_pos = pos + 1;
1765 rcu_read_lock();
1766 ipc_lock_object(ipc);
1767 return ipc;
1768 diff --git a/kernel/audit.c b/kernel/audit.c
1769 index 53dcaa3b67bc..af1e00f52bd0 100644
1770 --- a/kernel/audit.c
1771 +++ b/kernel/audit.c
1772 @@ -941,6 +941,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1773 case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
1774 if (!audit_enabled && msg_type != AUDIT_USER_AVC)
1775 return 0;
1776 + /* exit early if there isn't at least one character to print */
1777 + if (data_len < 2)
1778 + return -EINVAL;
1779
1780 err = audit_filter(msg_type, AUDIT_FILTER_USER);
1781 if (err == 1) { /* match or error */
1782 diff --git a/kernel/events/core.c b/kernel/events/core.c
1783 index 97b90faceb97..1f27b73bd7d4 100644
1784 --- a/kernel/events/core.c
1785 +++ b/kernel/events/core.c
1786 @@ -6431,10 +6431,17 @@ static void perf_event_task_output(struct perf_event *event,
1787 goto out;
1788
1789 task_event->event_id.pid = perf_event_pid(event, task);
1790 - task_event->event_id.ppid = perf_event_pid(event, current);
1791 -
1792 task_event->event_id.tid = perf_event_tid(event, task);
1793 - task_event->event_id.ptid = perf_event_tid(event, current);
1794 +
1795 + if (task_event->event_id.header.type == PERF_RECORD_EXIT) {
1796 + task_event->event_id.ppid = perf_event_pid(event,
1797 + task->real_parent);
1798 + task_event->event_id.ptid = perf_event_pid(event,
1799 + task->real_parent);
1800 + } else { /* PERF_RECORD_FORK */
1801 + task_event->event_id.ppid = perf_event_pid(event, current);
1802 + task_event->event_id.ptid = perf_event_tid(event, current);
1803 + }
1804
1805 task_event->event_id.time = perf_event_clock(event);
1806
1807 diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
1808 index edf67c493a8e..e473f6a1f6ca 100644
1809 --- a/kernel/gcov/fs.c
1810 +++ b/kernel/gcov/fs.c
1811 @@ -108,9 +108,9 @@ static void *gcov_seq_next(struct seq_file *seq, void *data, loff_t *pos)
1812 {
1813 struct gcov_iterator *iter = data;
1814
1815 + (*pos)++;
1816 if (gcov_iter_next(iter))
1817 return NULL;
1818 - (*pos)++;
1819
1820 return iter;
1821 }
1822 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
1823 index 153deec1df35..c74a087fcb7d 100644
1824 --- a/mm/vmalloc.c
1825 +++ b/mm/vmalloc.c
1826 @@ -31,6 +31,7 @@
1827 #include <linux/compiler.h>
1828 #include <linux/llist.h>
1829 #include <linux/bitops.h>
1830 +#include <linux/overflow.h>
1831
1832 #include <asm/uaccess.h>
1833 #include <asm/tlbflush.h>
1834 @@ -2173,6 +2174,7 @@ finished:
1835 * @vma: vma to cover
1836 * @uaddr: target user address to start at
1837 * @kaddr: virtual address of vmalloc kernel memory
1838 + * @pgoff: offset from @kaddr to start at
1839 * @size: size of map area
1840 *
1841 * Returns: 0 for success, -Exxx on failure
1842 @@ -2185,9 +2187,15 @@ finished:
1843 * Similar to remap_pfn_range() (see mm/memory.c)
1844 */
1845 int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
1846 - void *kaddr, unsigned long size)
1847 + void *kaddr, unsigned long pgoff,
1848 + unsigned long size)
1849 {
1850 struct vm_struct *area;
1851 + unsigned long off;
1852 + unsigned long end_index;
1853 +
1854 + if (check_shl_overflow(pgoff, PAGE_SHIFT, &off))
1855 + return -EINVAL;
1856
1857 size = PAGE_ALIGN(size);
1858
1859 @@ -2201,8 +2209,10 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
1860 if (!(area->flags & VM_USERMAP))
1861 return -EINVAL;
1862
1863 - if (kaddr + size > area->addr + get_vm_area_size(area))
1864 + if (check_add_overflow(size, off, &end_index) ||
1865 + end_index > get_vm_area_size(area))
1866 return -EINVAL;
1867 + kaddr += off;
1868
1869 do {
1870 struct page *page = vmalloc_to_page(kaddr);
1871 @@ -2241,7 +2251,7 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
1872 unsigned long pgoff)
1873 {
1874 return remap_vmalloc_range_partial(vma, vma->vm_start,
1875 - addr + (pgoff << PAGE_SHIFT),
1876 + addr, pgoff,
1877 vma->vm_end - vma->vm_start);
1878 }
1879 EXPORT_SYMBOL(remap_vmalloc_range);
1880 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
1881 index 58e0dab06f19..8afb67a48409 100644
1882 --- a/net/ipv4/ip_vti.c
1883 +++ b/net/ipv4/ip_vti.c
1884 @@ -696,10 +696,8 @@ static int __init vti_init(void)
1885
1886 msg = "ipip tunnel";
1887 err = xfrm4_tunnel_register(&ipip_handler, AF_INET);
1888 - if (err < 0) {
1889 - pr_info("%s: cant't register tunnel\n",__func__);
1890 + if (err < 0)
1891 goto xfrm_tunnel_failed;
1892 - }
1893
1894 msg = "netlink interface";
1895 err = rtnl_link_register(&vti_link_ops);
1896 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
1897 index ed53bf5d2b68..af75c0a8238e 100644
1898 --- a/net/ipv4/raw.c
1899 +++ b/net/ipv4/raw.c
1900 @@ -509,9 +509,11 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
1901 goto out;
1902
1903 /* hdrincl should be READ_ONCE(inet->hdrincl)
1904 - * but READ_ONCE() doesn't work with bit fields
1905 + * but READ_ONCE() doesn't work with bit fields.
1906 + * Doing this indirectly yields the same result.
1907 */
1908 hdrincl = inet->hdrincl;
1909 + hdrincl = READ_ONCE(hdrincl);
1910 /*
1911 * Check the flags.
1912 */
1913 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
1914 index 8f5c6fa54ac0..b4f24eabfa54 100644
1915 --- a/net/ipv4/route.c
1916 +++ b/net/ipv4/route.c
1917 @@ -131,8 +131,6 @@ static int ip_rt_min_advmss __read_mostly = 256;
1918
1919 static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT;
1920
1921 -static int ip_min_valid_pmtu __read_mostly = IPV4_MIN_MTU;
1922 -
1923 /*
1924 * Interface to generic destination cache.
1925 */
1926 @@ -2712,6 +2710,7 @@ void ip_rt_multicast_event(struct in_device *in_dev)
1927 static int ip_rt_gc_interval __read_mostly = 60 * HZ;
1928 static int ip_rt_gc_min_interval __read_mostly = HZ / 2;
1929 static int ip_rt_gc_elasticity __read_mostly = 8;
1930 +static int ip_min_valid_pmtu __read_mostly = IPV4_MIN_MTU;
1931
1932 static int ipv4_sysctl_rtcache_flush(struct ctl_table *__ctl, int write,
1933 void __user *buffer,
1934 diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
1935 index 7ee6518afa86..73705a2368d9 100644
1936 --- a/net/ipv4/xfrm4_output.c
1937 +++ b/net/ipv4/xfrm4_output.c
1938 @@ -75,9 +75,7 @@ int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb)
1939 {
1940 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
1941
1942 -#ifdef CONFIG_NETFILTER
1943 IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED;
1944 -#endif
1945
1946 return xfrm_output(sk, skb);
1947 }
1948 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
1949 index 1080770b5eaf..455fa4a30353 100644
1950 --- a/net/ipv6/ipv6_sockglue.c
1951 +++ b/net/ipv6/ipv6_sockglue.c
1952 @@ -184,15 +184,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
1953 retv = -EBUSY;
1954 break;
1955 }
1956 - } else if (sk->sk_protocol == IPPROTO_TCP) {
1957 - if (sk->sk_prot != &tcpv6_prot) {
1958 - retv = -EBUSY;
1959 - break;
1960 - }
1961 - break;
1962 - } else {
1963 + }
1964 + if (sk->sk_protocol == IPPROTO_TCP &&
1965 + sk->sk_prot != &tcpv6_prot) {
1966 + retv = -EBUSY;
1967 break;
1968 }
1969 + if (sk->sk_protocol != IPPROTO_TCP)
1970 + break;
1971 if (sk->sk_state != TCP_ESTABLISHED) {
1972 retv = -ENOTCONN;
1973 break;
1974 diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
1975 index 64862c5084ee..b2dc9a820c6a 100644
1976 --- a/net/ipv6/xfrm6_output.c
1977 +++ b/net/ipv6/xfrm6_output.c
1978 @@ -125,9 +125,7 @@ int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb)
1979 {
1980 memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
1981
1982 -#ifdef CONFIG_NETFILTER
1983 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
1984 -#endif
1985
1986 return xfrm_output(sk, skb);
1987 }
1988 diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
1989 index d72a4f1558f2..ef6a3d586591 100644
1990 --- a/net/netrom/nr_route.c
1991 +++ b/net/netrom/nr_route.c
1992 @@ -199,6 +199,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
1993 /* refcount initialized at 1 */
1994 spin_unlock_bh(&nr_node_list_lock);
1995
1996 + nr_neigh_put(nr_neigh);
1997 return 0;
1998 }
1999 nr_node_lock(nr_node);
2000 diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c
2001 index 39231237e1c3..30f71620d4e3 100644
2002 --- a/net/x25/x25_dev.c
2003 +++ b/net/x25/x25_dev.c
2004 @@ -120,8 +120,10 @@ int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev,
2005 goto drop;
2006 }
2007
2008 - if (!pskb_may_pull(skb, 1))
2009 + if (!pskb_may_pull(skb, 1)) {
2010 + x25_neigh_put(nb);
2011 return 0;
2012 + }
2013
2014 switch (skb->data[0]) {
2015
2016 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
2017 index d8e132a2d1a8..ab16b81c0c7f 100644
2018 --- a/sound/pci/hda/hda_intel.c
2019 +++ b/sound/pci/hda/hda_intel.c
2020 @@ -1967,7 +1967,6 @@ static const struct hdac_io_ops pci_hda_io_ops = {
2021 * should be ignored from the beginning.
2022 */
2023 static const struct snd_pci_quirk driver_blacklist[] = {
2024 - SND_PCI_QUIRK(0x1043, 0x874f, "ASUS ROG Zenith II / Strix", 0),
2025 SND_PCI_QUIRK(0x1462, 0xcb59, "MSI TRX40 Creator", 0),
2026 SND_PCI_QUIRK(0x1462, 0xcb60, "MSI TRX40", 0),
2027 {}
2028 diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
2029 index b3464ac99b99..ec8be720d5cd 100644
2030 --- a/sound/soc/intel/atom/sst-atom-controls.c
2031 +++ b/sound/soc/intel/atom/sst-atom-controls.c
2032 @@ -976,7 +976,9 @@ static int sst_set_be_modules(struct snd_soc_dapm_widget *w,
2033 dev_dbg(c->dev, "Enter: widget=%s\n", w->name);
2034
2035 if (SND_SOC_DAPM_EVENT_ON(event)) {
2036 + mutex_lock(&drv->lock);
2037 ret = sst_send_slot_map(drv);
2038 + mutex_unlock(&drv->lock);
2039 if (ret)
2040 return ret;
2041 ret = sst_send_pipe_module_params(w, k);
2042 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
2043 index 73523cf0329b..41a29bb21519 100644
2044 --- a/sound/soc/soc-dapm.c
2045 +++ b/sound/soc/soc-dapm.c
2046 @@ -384,7 +384,7 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
2047
2048 memset(&template, 0, sizeof(template));
2049 template.reg = e->reg;
2050 - template.mask = e->mask << e->shift_l;
2051 + template.mask = e->mask;
2052 template.shift = e->shift_l;
2053 template.off_val = snd_soc_enum_item_to_val(e, 0);
2054 template.on_val = template.off_val;
2055 @@ -510,8 +510,22 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol,
2056 if (data->value == value)
2057 return false;
2058
2059 - if (data->widget)
2060 - data->widget->on_val = value;
2061 + if (data->widget) {
2062 + switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) {
2063 + case snd_soc_dapm_switch:
2064 + case snd_soc_dapm_mixer:
2065 + case snd_soc_dapm_mixer_named_ctl:
2066 + data->widget->on_val = value & data->widget->mask;
2067 + break;
2068 + case snd_soc_dapm_demux:
2069 + case snd_soc_dapm_mux:
2070 + data->widget->on_val = value >> data->widget->shift;
2071 + break;
2072 + default:
2073 + data->widget->on_val = value;
2074 + break;
2075 + }
2076 + }
2077
2078 data->value = value;
2079
2080 diff --git a/sound/usb/format.c b/sound/usb/format.c
2081 index 2c44386e5569..eeb56d6fe8aa 100644
2082 --- a/sound/usb/format.c
2083 +++ b/sound/usb/format.c
2084 @@ -220,6 +220,52 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
2085 return 0;
2086 }
2087
2088 +/*
2089 + * Many Focusrite devices supports a limited set of sampling rates per
2090 + * altsetting. Maximum rate is exposed in the last 4 bytes of Format Type
2091 + * descriptor which has a non-standard bLength = 10.
2092 + */
2093 +static bool focusrite_valid_sample_rate(struct snd_usb_audio *chip,
2094 + struct audioformat *fp,
2095 + unsigned int rate)
2096 +{
2097 + struct usb_interface *iface;
2098 + struct usb_host_interface *alts;
2099 + unsigned char *fmt;
2100 + unsigned int max_rate;
2101 +
2102 + iface = usb_ifnum_to_if(chip->dev, fp->iface);
2103 + if (!iface)
2104 + return true;
2105 +
2106 + alts = &iface->altsetting[fp->altset_idx];
2107 + fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen,
2108 + NULL, UAC_FORMAT_TYPE);
2109 + if (!fmt)
2110 + return true;
2111 +
2112 + if (fmt[0] == 10) { /* bLength */
2113 + max_rate = combine_quad(&fmt[6]);
2114 +
2115 + /* Validate max rate */
2116 + if (max_rate != 48000 &&
2117 + max_rate != 96000 &&
2118 + max_rate != 192000 &&
2119 + max_rate != 384000) {
2120 +
2121 + usb_audio_info(chip,
2122 + "%u:%d : unexpected max rate: %u\n",
2123 + fp->iface, fp->altsetting, max_rate);
2124 +
2125 + return true;
2126 + }
2127 +
2128 + return rate <= max_rate;
2129 + }
2130 +
2131 + return true;
2132 +}
2133 +
2134 /*
2135 * Helper function to walk the array of sample rate triplets reported by
2136 * the device. The problem is that we need to parse whole array first to
2137 @@ -256,6 +302,11 @@ static int parse_uac2_sample_rate_range(struct snd_usb_audio *chip,
2138 }
2139
2140 for (rate = min; rate <= max; rate += res) {
2141 + /* Filter out invalid rates on Focusrite devices */
2142 + if (USB_ID_VENDOR(chip->usb_id) == 0x1235 &&
2143 + !focusrite_valid_sample_rate(chip, fp, rate))
2144 + goto skip_rate;
2145 +
2146 if (fp->rate_table)
2147 fp->rate_table[nr_rates] = rate;
2148 if (!fp->rate_min || rate < fp->rate_min)
2149 @@ -270,6 +321,7 @@ static int parse_uac2_sample_rate_range(struct snd_usb_audio *chip,
2150 break;
2151 }
2152
2153 +skip_rate:
2154 /* avoid endless loop */
2155 if (res == 0)
2156 break;
2157 diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
2158 index f4fd9548c529..723b535ca2ec 100644
2159 --- a/sound/usb/mixer_quirks.c
2160 +++ b/sound/usb/mixer_quirks.c
2161 @@ -1519,11 +1519,15 @@ static int snd_microii_spdif_default_get(struct snd_kcontrol *kcontrol,
2162
2163 /* use known values for that card: interface#1 altsetting#1 */
2164 iface = usb_ifnum_to_if(chip->dev, 1);
2165 - if (!iface || iface->num_altsetting < 2)
2166 - return -EINVAL;
2167 + if (!iface || iface->num_altsetting < 2) {
2168 + err = -EINVAL;
2169 + goto end;
2170 + }
2171 alts = &iface->altsetting[1];
2172 - if (get_iface_desc(alts)->bNumEndpoints < 1)
2173 - return -EINVAL;
2174 + if (get_iface_desc(alts)->bNumEndpoints < 1) {
2175 + err = -EINVAL;
2176 + goto end;
2177 + }
2178 ep = get_endpoint(alts, 0)->bEndpointAddress;
2179
2180 err = snd_usb_ctl_msg(chip->dev,
2181 diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
2182 index dd40ca9d858a..4f81fedf0e54 100644
2183 --- a/sound/usb/usx2y/usbusx2yaudio.c
2184 +++ b/sound/usb/usx2y/usbusx2yaudio.c
2185 @@ -691,6 +691,8 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
2186 us->submitted = 2*NOOF_SETRATE_URBS;
2187 for (i = 0; i < NOOF_SETRATE_URBS; ++i) {
2188 struct urb *urb = us->urb[i];
2189 + if (!urb)
2190 + continue;
2191 if (urb->status) {
2192 if (!err)
2193 err = -ENODEV;
2194 diff --git a/tools/objtool/check.c b/tools/objtool/check.c
2195 index db105207757b..360845926f66 100644
2196 --- a/tools/objtool/check.c
2197 +++ b/tools/objtool/check.c
2198 @@ -2035,14 +2035,27 @@ static bool ignore_unreachable_insn(struct instruction *insn)
2199 !strcmp(insn->sec->name, ".altinstr_aux"))
2200 return true;
2201
2202 + if (!insn->func)
2203 + return false;
2204 +
2205 + /*
2206 + * CONFIG_UBSAN_TRAP inserts a UD2 when it sees
2207 + * __builtin_unreachable(). The BUG() macro has an unreachable() after
2208 + * the UD2, which causes GCC's undefined trap logic to emit another UD2
2209 + * (or occasionally a JMP to UD2).
2210 + */
2211 + if (list_prev_entry(insn, list)->dead_end &&
2212 + (insn->type == INSN_BUG ||
2213 + (insn->type == INSN_JUMP_UNCONDITIONAL &&
2214 + insn->jump_dest && insn->jump_dest->type == INSN_BUG)))
2215 + return true;
2216 +
2217 /*
2218 * Check if this (or a subsequent) instruction is related to
2219 * CONFIG_UBSAN or CONFIG_KASAN.
2220 *
2221 * End the search at 5 instructions to avoid going into the weeds.
2222 */
2223 - if (!insn->func)
2224 - return false;
2225 for (i = 0; i < 5; i++) {
2226
2227 if (is_kasan_insn(insn) || is_ubsan_insn(insn))
2228 diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c
2229 index c3343820916a..7cbbbdd932f1 100644
2230 --- a/tools/objtool/orc_dump.c
2231 +++ b/tools/objtool/orc_dump.c
2232 @@ -78,7 +78,7 @@ int orc_dump(const char *_objname)
2233 char *name;
2234 size_t nr_sections;
2235 Elf64_Addr orc_ip_addr = 0;
2236 - size_t shstrtab_idx;
2237 + size_t shstrtab_idx, strtab_idx = 0;
2238 Elf *elf;
2239 Elf_Scn *scn;
2240 GElf_Shdr sh;
2241 @@ -139,6 +139,8 @@ int orc_dump(const char *_objname)
2242
2243 if (!strcmp(name, ".symtab")) {
2244 symtab = data;
2245 + } else if (!strcmp(name, ".strtab")) {
2246 + strtab_idx = i;
2247 } else if (!strcmp(name, ".orc_unwind")) {
2248 orc = data->d_buf;
2249 orc_size = sh.sh_size;
2250 @@ -150,7 +152,7 @@ int orc_dump(const char *_objname)
2251 }
2252 }
2253
2254 - if (!symtab || !orc || !orc_ip)
2255 + if (!symtab || !strtab_idx || !orc || !orc_ip)
2256 return 0;
2257
2258 if (orc_size % sizeof(*orc) != 0) {
2259 @@ -171,21 +173,29 @@ int orc_dump(const char *_objname)
2260 return -1;
2261 }
2262
2263 - scn = elf_getscn(elf, sym.st_shndx);
2264 - if (!scn) {
2265 - WARN_ELF("elf_getscn");
2266 - return -1;
2267 - }
2268 -
2269 - if (!gelf_getshdr(scn, &sh)) {
2270 - WARN_ELF("gelf_getshdr");
2271 - return -1;
2272 - }
2273 -
2274 - name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
2275 - if (!name || !*name) {
2276 - WARN_ELF("elf_strptr");
2277 - return -1;
2278 + if (GELF_ST_TYPE(sym.st_info) == STT_SECTION) {
2279 + scn = elf_getscn(elf, sym.st_shndx);
2280 + if (!scn) {
2281 + WARN_ELF("elf_getscn");
2282 + return -1;
2283 + }
2284 +
2285 + if (!gelf_getshdr(scn, &sh)) {
2286 + WARN_ELF("gelf_getshdr");
2287 + return -1;
2288 + }
2289 +
2290 + name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
2291 + if (!name) {
2292 + WARN_ELF("elf_strptr");
2293 + return -1;
2294 + }
2295 + } else {
2296 + name = elf_strptr(elf, strtab_idx, sym.st_name);
2297 + if (!name) {
2298 + WARN_ELF("elf_strptr");
2299 + return -1;
2300 + }
2301 }
2302
2303 printf("%s+%llx:", name, (unsigned long long)rela.r_addend);