4.4.42-stable review
Subsystems (3)
Greg Kroah-Hartman
maintainercover 4.4.42-stable review
This is the start of the stable review cycle for the 4.4.42 release. There are 101 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jan 12 13:15:04 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.42-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.4.42-rc1
Thomas Gleixner <[email protected]>
tick/broadcast: Prevent NULL pointer dereference
Michel Dänzer <[email protected]>
drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values
Mauro Carvalho Chehab <[email protected]>
cx23885-dvb: move initialization of a8293_pdata
Arnd Bergmann <[email protected]>
net: vxge: avoid unused function warnings
Paul Burton <[email protected]>
net: ti: cpmac: Fix compiler warning due to type confusion
Arnd Bergmann <[email protected]>
cred/userns: define current_user_ns() as a function
H Hartley Sweeten <[email protected]>
staging: comedi: dt282x: tidy up register bit defines
Johan Hovold <[email protected]>
powerpc/pci/rpadlpar: Fix device reference leaks
Shaohua Li <[email protected]>
md: MD_RECOVERY_NEEDED is set for mddev->recovery
Ard Biesheuvel <[email protected]>
crypto: arm64/aes-ce - fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/aes-xts-ce: fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/sha1-ce - fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/aes-neon - fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/aes-ccm-ce: fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm/aes-ce - fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/ghash-ce - fix for big endian
Ard Biesheuvel <[email protected]>
crypto: arm64/sha2-ce - fix for big endian
Dan Carpenter <[email protected]>
s390/crypto: unlock on error in prng_tdes_read()
Dan Carpenter <[email protected]>
mmc: mmc_test: Uninitialized return value
Tony Lindgren <[email protected]>
PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend
Florian Fainelli <[email protected]>
irqchip/bcm7038-l1: Implement irq_cpu_offline() callback
Dan Carpenter <[email protected]>
target/iscsi: Fix double free in lio_target_tiqn_addtpg()
Arnd Bergmann <[email protected]>
scsi: mvsas: fix command_active typo
Charles Keepax <[email protected]>
ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call
Xunlei Pang <[email protected]>
iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped
Jacob Pan <[email protected]>
iommu/vt-d: Fix pasid table size encoding
Huang Rui <[email protected]>
iommu/amd: Fix the left value check of cmd buffer
Dan Carpenter <[email protected]>
iommu/amd: Missing error code in amd_iommu_init_device()
Vladimir Zapolskiy <[email protected]>
clk: imx31: fix rewritten input argument of mx31_clocks_init()
Pan Bian <[email protected]>
clk: clk-wm831x: fix a logic error
Guenter Roeck <[email protected]>
hwmon: (g762) Fix overflows and crash seen when writing limit attributes
Guenter Roeck <[email protected]>
hwmon: (nct7802) Fix overflows seen when writing into limit attributes
Guenter Roeck <[email protected]>
hwmon: (ds620) Fix overflows seen when writing temperature limits
Jared Bents <[email protected]>
hwmon: (amc6821) sign extension temperature
Javier Martinez Canillas <[email protected]>
hwmon: (scpi) Fix module autoload
Guenter Roeck <[email protected]>
cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected
Nicolas Iooss <[email protected]>
ath10k: use the right length of "background"
Arnd Bergmann <[email protected]>
stable-fixup: hotplug: fix unused function warning
Felipe Balbi <[email protected]>
usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()
Felipe Balbi <[email protected]>
usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb()
Felipe Balbi <[email protected]>
usb: dwc3: gadget: always unmap EP0 requests
Eva Rachel Retuya <[email protected]>
staging: iio: ad7606: fix improper setting of oversampling pins
Alexander Usyskin <[email protected]>
mei: bus: fix mei_cldev_enable KDoc
Johan Hovold <[email protected]>
USB: serial: io_ti: bind to interface after fw download
Johan Hovold <[email protected]>
USB: phy: am335x-control: fix device and of_node leaks
Geert Uytterhoeven <[email protected]>
ARM: dts: r8a7794: Correct hsusb parent clock
Pan Bian <[email protected]>
USB: serial: kl5kusb105: abort on open exception path
Takashi Iwai <[email protected]>
ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream()
Jérémy Lefaure <[email protected]>
usb: musb: blackfin: add bfin_fifo_offset in bfin_ops
Geert Uytterhoeven <[email protected]>
usb: hub: Move hub_port_disable() to fix warning if PM is disabled
Tony Lindgren <[email protected]>
usb: musb: Fix trying to free already-free IRQ 4
Heikki Krogerus <[email protected]>
usb: dwc3: pci: add Intel Gemini Lake PCI ID
OGAWA Hirofumi <[email protected]>
xhci: Fix race related to abort operation
OGAWA Hirofumi <[email protected]>
xhci: Use delayed_work instead of timer for command timeout
Dan Carpenter <[email protected]>
usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL
Johan Hovold <[email protected]>
USB: serial: mos7720: fix parallel probe
Johan Hovold <[email protected]>
USB: serial: mos7720: fix parport use-after-free on probe errors
Johan Hovold <[email protected]>
USB: serial: mos7720: fix use-after-free on probe errors
Johan Hovold <[email protected]>
USB: serial: mos7720: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: mos7840: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: kobil_sct: fix NULL-deref in write
Johan Hovold <[email protected]>
USB: serial: cyberjack: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: oti6858: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: io_edgeport: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: ti_usb_3410_5052: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: garmin_gps: fix memory leak on failed URB submit
Johan Hovold <[email protected]>
USB: serial: iuu_phoenix: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: io_ti: fix I/O after disconnect
Johan Hovold <[email protected]>
USB: serial: io_ti: fix another NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: io_ti: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: spcp8x5: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: keyspan_pda: verify endpoints at probe
Johan Hovold <[email protected]>
USB: serial: pl2303: fix NULL-deref at open
Johan Hovold <[email protected]>
USB: serial: quatech2: fix sleep-while-atomic in close
Johan Hovold <[email protected]>
USB: serial: omninet: fix NULL-derefs at open and disconnect
Lu Baolu <[email protected]>
usb: xhci: hold lock over xhci_abort_cmd_ring()
Mathias Nyman <[email protected]>
xhci: Handle command completion and timeout race
Baolin Wang <[email protected]>
usb: host: xhci: Fix possible wild pointer when handling abort command
Lu Baolu <[email protected]>
usb: xhci: fix return value of xhci_setup_device()
Mathias Nyman <[email protected]>
xhci: free xhci virtual devices with leaf nodes first
Wan Ahmad Zainie <[email protected]>
usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake
Mathias Nyman <[email protected]>
xhci: workaround for hosts missing CAS bit
Lu Baolu <[email protected]>
usb: xhci: fix possible wild pointer
Felipe Balbi <[email protected]>
usb: dwc3: core: avoid Overflow events
Krzysztof Opasiak <[email protected]>
usb: gadget: composite: Test get_alt() presence instead of set_alt()
Alan Stern <[email protected]>
USB: dummy-hcd: fix bug in stop_activity (handle ep0)
Alan Stern <[email protected]>
USB: fix problems with duplicate endpoint addresses
Alan Stern <[email protected]>
USB: gadgetfs: fix checks of wTotalLength in config descriptors
Alan Stern <[email protected]>
USB: gadgetfs: fix use-after-free bug
Alan Stern <[email protected]>
USB: gadgetfs: fix unbounded memory allocation bug
Greg Kroah-Hartman <[email protected]>
usb: gadgetfs: restrict upper bound on device configuration size
Oliver Neukum <[email protected]>
usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
Bin Liu <[email protected]>
usb: musb: dsps: implement clear_ep_rxintr() callback
Bin Liu <[email protected]>
usb: musb: core: add clear_ep_rxintr() to musb_platform_ops
James Hogan <[email protected]>
KVM: MIPS: Flush KVM entry code from icache globally
Xiao Guangrong <[email protected]>
KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS
Johannes Berg <[email protected]>
mac80211: initialize fast-xmit 'info' later
Bartosz Golaszewski <[email protected]>
ARM: davinci: da850: don't add emac clock to lookup table twice
Ioan-Adrian Ratiu <[email protected]>
ALSA: usb-audio: Fix irq/process data synchronization
Takashi Iwai <[email protected]>
ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL
Takashi Iwai <[email protected]>
ALSA: hda - Fix up GPIO for ASUS ROG Ranger
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/r8a7794.dtsi | 2 +- arch/arm/crypto/aes-ce-glue.c | 5 + arch/arm/mach-davinci/da850.c | 12 +- arch/arm64/crypto/aes-ce-ccm-core.S | 53 +++--- arch/arm64/crypto/aes-ce-cipher.c | 25 +-- arch/arm64/crypto/aes-ce.S | 1 + arch/arm64/crypto/aes-modes.S | 3 +- arch/arm64/crypto/aes-neon.S | 25 +-- arch/arm64/crypto/ghash-ce-core.S | 6 +- arch/arm64/crypto/sha1-ce-core.S | 4 +- arch/arm64/crypto/sha2-ce-core.S | 4 +- arch/cris/boot/rescue/Makefile | 8 + arch/mips/kvm/mips.c | 4 +- arch/s390/crypto/prng.c | 6 +- arch/x86/kvm/x86.c | 9 +- drivers/base/power/power.h | 19 ++- drivers/base/power/runtime.c | 8 +- drivers/base/power/wakeirq.c | 76 +++++++-- drivers/clk/clk-wm831x.c | 2 +- drivers/clk/imx/clk-imx31.c | 4 +- drivers/gpu/drm/radeon/radeon_cursor.c | 6 +- drivers/hwmon/amc6821.c | 4 +- drivers/hwmon/ds620.c | 2 +- drivers/hwmon/g762.c | 11 +- drivers/hwmon/nct7802.c | 8 +- drivers/hwmon/scpi-hwmon.c | 1 + drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/amd_iommu_v2.c | 4 +- drivers/iommu/intel-iommu.c | 42 ++++- drivers/irqchip/irq-bcm7038-l1.c | 26 +++ drivers/md/md.c | 2 +- drivers/media/pci/cx23885/cx23885-dvb.c | 6 +- drivers/misc/mei/bus.c | 2 +- drivers/mmc/card/mmc_test.c | 2 +- drivers/net/ethernet/neterion/vxge/vxge-main.c | 31 ++-- drivers/net/ethernet/ti/cpmac.c | 5 +- drivers/net/wireless/ath/ath10k/spectral.c | 2 +- drivers/pci/hotplug/rpadlpar_core.c | 10 +- drivers/scsi/mvsas/mv_94xx.c | 2 +- drivers/staging/comedi/drivers/dt282x.c | 65 ++++---- drivers/staging/iio/adc/ad7606_core.c | 2 +- drivers/target/iscsi/iscsi_target_tpg.c | 1 - drivers/usb/core/config.c | 10 ++ drivers/usb/core/hub.c | 59 ++++--- drivers/usb/dwc3/core.h | 4 +- drivers/usb/dwc3/dwc3-pci.c | 2 + drivers/usb/dwc3/ep0.c | 50 +++--- drivers/usb/dwc3/gadget.c | 8 +- drivers/usb/gadget/composite.c | 12 +- drivers/usb/gadget/legacy/inode.c | 17 +- drivers/usb/gadget/udc/dummy_hcd.c | 6 +- drivers/usb/host/xhci-hub.c | 37 +++++ drivers/usb/host/xhci-mem.c | 50 +++++- drivers/usb/host/xhci-pci.c | 9 +- drivers/usb/host/xhci-ring.c | 219 ++++++++++++++----------- drivers/usb/host/xhci.c | 4 +- drivers/usb/host/xhci.h | 8 +- drivers/usb/musb/blackfin.c | 1 + drivers/usb/musb/musb_core.h | 7 + drivers/usb/musb/musb_dsps.c | 12 ++ drivers/usb/musb/musb_host.c | 10 +- drivers/usb/musb/musbhsdma.h | 2 +- drivers/usb/phy/phy-am335x-control.c | 2 + drivers/usb/serial/cyberjack.c | 10 ++ drivers/usb/serial/garmin_gps.c | 1 + drivers/usb/serial/io_edgeport.c | 5 + drivers/usb/serial/io_ti.c | 22 ++- drivers/usb/serial/iuu_phoenix.c | 11 ++ drivers/usb/serial/keyspan_pda.c | 14 ++ drivers/usb/serial/kl5kusb105.c | 2 + drivers/usb/serial/kobil_sct.c | 12 ++ drivers/usb/serial/mos7720.c | 51 +++--- drivers/usb/serial/mos7840.c | 12 ++ drivers/usb/serial/omninet.c | 13 ++ drivers/usb/serial/oti6858.c | 16 ++ drivers/usb/serial/pl2303.c | 8 + drivers/usb/serial/quatech2.c | 4 - drivers/usb/serial/spcp8x5.c | 14 ++ drivers/usb/serial/ti_usb_3410_5052.c | 7 + drivers/usb/storage/unusual_devs.h | 7 + include/linux/capability.h | 2 - include/linux/cred.h | 5 +- kernel/cpu.c | 9 +- kernel/time/tick-broadcast.c | 3 + net/mac80211/tx.c | 3 +- sound/pci/hda/patch_realtek.c | 2 + sound/soc/samsung/i2s.c | 5 +- sound/usb/card.c | 1 - sound/usb/endpoint.c | 17 +- sound/usb/endpoint.h | 2 +- sound/usb/pcm.c | 10 +- 92 files changed, 903 insertions(+), 410 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/101 ALSA: hda - Fix up GPIO for ASUS ROG Ranger
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 85bcf96caba8b4a7c0805555638629ba3c67ea0c upstream.
ASUS ROG Ranger VIII with ALC1150 codec requires the extra GPIO pin to up for the front panel. Just use the existing fixup for setting up the GPIO pins.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189411
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -2230,6 +2230,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x1043 ,0x1971 ,"Asus W2JC" ,ALC882_FIXUP_ASUS_W2JC ),SND_PCI_QUIRK (0x1043 ,0x835f ,"Asus Eee 1601" ,ALC888_FIXUP_EEE1601 ),SND_PCI_QUIRK (0x1043 ,0x84bc ,"ASUS ET2700" ,ALC887_FIXUP_ASUS_BASS ), +SND_PCI_QUIRK (0x1043 ,0x8691 ,"ASUS ROG Ranger VIII" ,ALC882_FIXUP_GPIO3 ),SND_PCI_QUIRK (0x104d ,0x9047 ,"Sony Vaio TT" ,ALC889_FIXUP_VAIO_TT ),SND_PCI_QUIRK (0x104d ,0x905a ,"Sony Vaio Z" ,ALC882_FIXUP_NO_PRIMARY_HP ), SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
Greg Kroah-Hartman
maintainerPATCH 2/101 ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c7efff9284dfde95a11aaa811c9d8ec8167f0f6e upstream.
Although the old quirk table showed ASUS X71SL with ALC663 codec being compatible with asus-mode3 fixup, the bugzilla reporter explained that asus-model8 fits better for the dual headphone controls. So be it.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=191781
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -6893,6 +6893,7 @@ static const struct snd_pci_quirk alc662SND_PCI_QUIRK (0x1043 ,0x15a7 ,"ASUS UX51VZH" ,ALC662_FIXUP_BASS_16 ),SND_PCI_QUIRK (0x1043 ,0x177d ,"ASUS N551" , ALC668_FIXUP_ASUS_Nx51),SND_PCI_QUIRK (0x1043 ,0x17bd ,"ASUS N751" , ALC668_FIXUP_ASUS_Nx51), +SND_PCI_QUIRK (0x1043 ,0x1963 ,"ASUS X71SL" ,ALC662_FIXUP_ASUS_MODE8 ),SND_PCI_QUIRK (0x1043 ,0x1b73 ,"ASUS N55SF" ,ALC662_FIXUP_BASS_16 ),SND_PCI_QUIRK (0x1043 ,0x1bf3 ,"ASUS N76VZ" ,ALC662_FIXUP_BASS_MODE4_CHMAP ), SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
Greg Kroah-Hartman
maintainerPATCH 3/101 ALSA: usb-audio: Fix irq/process data synchronization
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ioan-Adrian Ratiu <[email protected]>
commit 1d0f953086f090a022f2c0e1448300c15372db46 upstream.
Commit 16200948d83 ("ALSA: usb-audio: Fix race at stopping the stream") was incomplete causing another more severe kernel panic, so it got reverted. This fixes both the original problem and its fallout kernel race/crash.
The original fix is to move the endpoint member NULL clearing logic inside wait_clear_urbs() so the irq triggering the urb completion doesn't call retire_capture/playback_urb() after the NULL clearing and generate a panic.
However this creates a new race between snd_usb_endpoint_start()'s call to wait_clear_urbs() and the irq urb completion handler which again calls retire_capture/playback_urb() leading to a new NULL dereference.
We keep the EP deactivation code in snd_usb_endpoint_start() because removing it will break the EP reference counting (see [1] [2] for info), however we don't need the "can_sleep" mechanism anymore because a new function was introduced (snd_usb_endpoint_sync_pending_stop()) which synchronizes pending stops and gets called inside the pcm prepare callback.
It also makes sense to remove can_sleep because it was also removed from deactivate_urbs() signature in [3] so we benefit from more simplification.
[1] commit 015618b90 ("ALSA: snd-usb: Fix URB cancellation at stream start")
[2] commit e9ba389c5 ("ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream")
[3] commit ccc1696d5 ("ALSA: usb-audio: simplify endpoint deactivation code")
--- sound/usb/endpoint.c | 17 +++++++---------- sound/usb/endpoint.h | 2 +- sound/usb/pcm.c | 10 +++++----- 3 files changed, 13 insertions(+), 16 deletions(-)
sound/usb/endpoint.c +7 -10
@@ -538,6 +538,11 @@ static int wait_clear_urbs(struct snd_us alive, ep->ep_num);clear_bit (EP_FLAG_STOPPING , &ep->flags); + ep->data_subs =NULL ; + ep->sync_slave =NULL ; + ep->retire_data_urb =NULL ; + ep->prepare_data_urb =NULL ; +return 0 ; }
@@ -902,9 +907,7 @@ int snd_usb_endpoint_set_params(struct s/** * snd_usb_endpoint_start: start an snd_usb_endpoint * -* @ep: the endpoint to start -* @can_sleep: flag indicating whether the operation is executed in -* non-atomic context +* @ep: the endpoint to start * * A call to this function will increment the use count of the endpoint. * In case it is not already running, the URBs for this endpoint will be
@@ -914,7 +917,7 @@ int snd_usb_endpoint_set_params(struct s* * Returns an error if the URB submission failed, 0 in all other cases. */ -int snd_usb_endpoint_start (struct snd_usb_endpoint *ep,bool can_sleep) +int snd_usb_endpoint_start (struct snd_usb_endpoint *ep) {int err;unsigned int i;
@@ -928,8 +931,6 @@ int snd_usb_endpoint_start(struct snd_us/* just to be sure */ deactivate_urbs (ep, false); -if (can_sleep) -wait_clear_urbs (ep); ep->active_mask =0 ; ep->unlink_mask =0 ;
@@ -1010,10 +1011,6 @@ void snd_usb_endpoint_stop(struct snd_usif (--ep->use_count ==0 ) {deactivate_urbs (ep, false); - ep->data_subs =NULL ; - ep->sync_slave =NULL ; - ep->retire_data_urb =NULL ; - ep->prepare_data_urb =NULL ;set_bit (EP_FLAG_STOPPING , &ep->flags); } }
sound/usb/endpoint.h +1 -1
@@ -18,7 +18,7 @@ int snd_usb_endpoint_set_params(struct sstruct audioformat *fmt, struct snd_usb_endpoint *sync_ep); -int snd_usb_endpoint_start (struct snd_usb_endpoint *ep,bool can_sleep); +int snd_usb_endpoint_start (struct snd_usb_endpoint *ep);void snd_usb_endpoint_stop (struct snd_usb_endpoint *ep);void snd_usb_endpoint_sync_pending_stop (struct snd_usb_endpoint *ep);int snd_usb_endpoint_activate (struct snd_usb_endpoint *ep);
sound/usb/pcm.c +5 -5
@@ -218,7 +218,7 @@ int snd_usb_init_pitch(struct snd_usb_au } } -static int start_endpoints (struct snd_usb_substream *subs,bool can_sleep) +static int start_endpoints (struct snd_usb_substream *subs) {int err;
@@ -231,7 +231,7 @@ static int start_endpoints(struct snd_usdev_dbg (&subs->dev->dev,"Starting data EP @%p\n" , ep); ep->data_subs = subs; - err =snd_usb_endpoint_start (ep, can_sleep); + err =snd_usb_endpoint_start (ep);if (err <0 ) {clear_bit (SUBSTREAM_FLAG_DATA_EP_STARTED , &subs->flags);return err;
@@ -260,7 +260,7 @@ static int start_endpoints(struct snd_usdev_dbg (&subs->dev->dev,"Starting sync EP @%p\n" , ep); ep->sync_slave = subs->data_endpoint; - err =snd_usb_endpoint_start (ep, can_sleep); + err =snd_usb_endpoint_start (ep);if (err <0 ) {clear_bit (SUBSTREAM_FLAG_SYNC_EP_STARTED , &subs->flags);return err;
@@ -839,7 +839,7 @@ static int snd_usb_pcm_prepare(struct sn/* for playback, submit the URBs now; otherwise, the first hwptr_done * updates for all URBs would happen at the same time when starting */ if (subs->direction ==SNDRV_PCM_STREAM_PLAYBACK ) - ret =start_endpoints (subs, true); + ret =start_endpoints (subs); unlock:snd_usb_unlock_shutdown (subs->stream->chip);
@@ -1655,7 +1655,7 @@ static int snd_usb_substream_capture_triswitch (cmd) {case SNDRV_PCM_TRIGGER_START : - err =start_endpoints (subs, false); + err =start_endpoints (subs);if (err <0 )return err;
Greg Kroah-Hartman
maintainerPATCH 4/101 ARM: davinci: da850: dont add emac clock to lookup table twice
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit ef37427ac5677331145ab27a17e6f5f1b43f0c11 upstream.
Similarly to the aemif clock - this screws up the linked list of clock children. Create a separate clock for mdio inheriting the rate from emac_clk.
[[email protected]: add a comment over mdio_clk to explaing its existence +
commit headline updates]
--- arch/arm/mach-davinci/da850.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/mach-davinci/da850.c +11 -1
@@ -298,6 +298,16 @@ static struct clk emac_clk = { .gpsc = 1, }; +/* +* In order to avoid adding the emac_clk to the clock lookup table twice (and +* screwing up the linked list in the process) create a separate clock for +* mdio inheriting the rate from emac_clk. +*/ +static struct clk mdio_clk = { + .name ="mdio" , + .parent = &emac_clk, +}; +static struct clk mcasp_clk = { .name ="mcasp" , .parent = &pll0_sysclk2,
@@ -462,7 +472,7 @@ static struct clk_lookup da850_clks[] =CLK (NULL ,"arm" , &arm_clk),CLK (NULL ,"rmii" , &rmii_clk),CLK ("davinci_emac.1" ,NULL , &emac_clk), -CLK ("davinci_mdio.0" ,"fck" , &emac_clk), +CLK ("davinci_mdio.0" ,"fck" , &mdio_clk),CLK ("davinci-mcasp.0" ,NULL , &mcasp_clk),CLK ("da8xx_lcdc.0" ,"fck" , &lcdc_clk), CLK("da830-mmc.0", NULL, &mmcsd0_clk),
Greg Kroah-Hartman
maintainerPATCH 5/101 mac80211: initialize fast-xmit info later
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 35f432a03e41d3bf08c51ede917f94e2288fbe8c upstream.
In ieee80211_xmit_fast(), 'info' is initialized to point to the skb that's passed in, but that skb may later be replaced by a clone (if it was shared), leading to an invalid pointer.
This can lead to use-after-free and also later crashes since the real SKB's info->hw_queue doesn't get initialized properly.
Fix this by assigning info only later, when it's needed, after the skb replacement (may have) happened.
--- net/mac80211/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tx.c +2 -1
@@ -2699,7 +2699,7 @@ static bool ieee80211_xmit_fast(struct iint extra_head = fast_tx->hdr_len - (ETH_HLEN -2 );int hw_headroom = sdata->local->hw.extra_tx_headroom;struct ethhdr eth; -struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_tx_info *info;struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;struct ieee80211_tx_data tx;ieee80211_tx_result r;
@@ -2761,6 +2761,7 @@ static bool ieee80211_xmit_fast(struct imemcpy (skb->data + fast_tx->da_offs, eth.h_dest,ETH_ALEN );memcpy (skb->data + fast_tx->sa_offs, eth.h_source,ETH_ALEN ); + info =IEEE80211_SKB_CB (skb);memset (info,0 ,sizeof (*info)); info->band = fast_tx->band; info->control.vif = &sdata->vif;
Greg Kroah-Hartman
maintainerPATCH 6/101 KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiao Guangrong <[email protected]>
commit 6ef4e07ecd2db21025c446327ecf34414366498b upstream.
Otherwise, mismatch between the smm bit in hflags and the MMU role can cause a NULL pointer dereference.
--- arch/x86/kvm/x86.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +7 -2
@@ -2949,6 +2949,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_memset (&events->reserved,0 ,sizeof (events->reserved)); } +static void kvm_set_hflags (struct kvm_vcpu *vcpu,unsigned emul_flags); +static int kvm_vcpu_ioctl_x86_set_vcpu_events (struct kvm_vcpu *vcpu,struct kvm_vcpu_events *events) {
@@ -2981,10 +2983,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_e vcpu->arch.apic->sipi_vector = events->sipi_vector;if (events->flags &KVM_VCPUEVENT_VALID_SMM ) { +u32 hflags = vcpu->arch.hflags;if (events->smi.smm) - vcpu->arch.hflags |=HF_SMM_MASK ; + hflags |=HF_SMM_MASK ;else - vcpu->arch.hflags &= ~HF_SMM_MASK ; + hflags &= ~HF_SMM_MASK ; +kvm_set_hflags (vcpu, hflags); + vcpu->arch.smi_pending = events->smi.pending;if (events->smi.smm_inside_nmi) vcpu->arch.hflags |=HF_SMM_INSIDE_NMI_MASK ;
Greg Kroah-Hartman
maintainerPATCH 7/101 KVM: MIPS: Flush KVM entry code from icache globally
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 32eb12a6c11034867401d56b012e3c15d5f8141e upstream.
Flush the KVM entry code from the icache on all CPUs, not just the one that built the entry code.
--- arch/mips/kvm/mips.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kvm/mips.c +2 -2
@@ -324,8 +324,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(st#endif /* Invalidate the icache for these ranges */ -local_flush_icache_range ((unsigned long )gebase, - (unsigned long )gebase +ALIGN (size,PAGE_SIZE )); +flush_icache_range ((unsigned long )gebase, + (unsigned long )gebase +ALIGN (size,PAGE_SIZE ));/* * Allocate comm page for guest kernel, a TLB will be reserved for
Greg Kroah-Hartman
maintainerPATCH 8/101 usb: musb: core: add clear_ep_rxintr() to musb_platform_ops
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit 6def85a396ce7796bd9f4561c6ae8138833f7a52 upstream.
During dma teardown for dequque urb, if musb load is high, musb might generate bogus rx ep interrupt even when the rx fifo is flushed. In such case any of the follow log messages could happen.
musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0 musb_host_rx 1936: RX3 dma busy, csr 2020
As mentioned in the current inline comment, clearing ep interrupt in the teardown path avoids the bogus interrupt.
Clearing ep interrupt is platform dependent, so this patch adds a platform callback to allow glue driver to clear the ep interrupt.
This bug seems to be existing since the initial driver for musb support, but I only validated the fix back to v4.1, so only cc stable for v4.1+.
--- drivers/usb/musb/musb_core.h | 7 +++++++ drivers/usb/musb/musb_host.c | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
drivers/usb/musb/musb_core.h +7 -0
@@ -214,6 +214,7 @@ struct musb_platform_ops { dma_addr_t *dma_addr, u32 *len);void (*pre_root_reset_end)(struct musb *musb);void (*post_root_reset_end)(struct musb *musb); +void (*clear_ep_rxintr)(struct musb *musb,int epnum); };/*
@@ -612,4 +613,10 @@ static inline void musb_platform_post_ro musb->ops->post_root_reset_end(musb); } +static inline void musb_platform_clear_ep_rxintr (struct musb *musb,int epnum) +{ +if (musb->ops->clear_ep_rxintr) + musb->ops->clear_ep_rxintr (musb, epnum); +} +#endif /* __MUSB_CORE_H__ */
drivers/usb/musb/musb_host.c +4 -6
@@ -2390,12 +2390,11 @@ static int musb_cleanup_urb(struct urb *int is_in =usb_pipein (urb->pipe);int status =0 ;u16 csr; +struct dma_channel *dma =NULL ;musb_ep_select (regs, hw_end);if (is_dma_capable ()) { -struct dma_channel *dma; - dma = is_in ? ep->rx_channel : ep->tx_channel;if (dma) { status = ep->musb->dma_controller->channel_abort (dma);
@@ -2412,10 +2411,9 @@ static int musb_cleanup_urb(struct urb */* giveback saves bulk toggle */ csr =musb_h_flush_rxfifo (ep,0 ); -/* REVISIT we still get an irq; should likely clear the -* endpoint's irq status here to avoid bogus irqs. -* clearing that status is platform-specific... -*/ +/* clear the endpoint's irq status here to avoid bogus irqs */ +if (is_dma_capable () && dma) +musb_platform_clear_ep_rxintr (musb, ep->epnum); }else if (ep->epnum) {musb_h_tx_flush_fifo (ep); csr =musb_readw (epio,MUSB_TXCSR );
Greg Kroah-Hartman
maintainerPATCH 9/101 usb: musb: dsps: implement clear_ep_rxintr() callback
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit c48400baa02155a5ddad63e8554602e48782278c upstream.
During dma teardown for dequque urb, if musb load is high, musb might generate bogus rx ep interrupt even when the rx fifo is flushed. In such case any of the follow log messages could happen.
musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0
musb_host_rx 1936: RX3 dma busy, csr 2020As mentioned in the current inline comment, clearing ep interrupt in the teardown path avoids the bogus interrupt, so implement clear_ep_rxintr() callback.
This bug seems to be existing since the initial driver for musb support, but I only validated the fix back to v4.1, so only cc stable for v4.1+.
--- drivers/usb/musb/musb_dsps.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/musb/musb_dsps.c +12 -0
@@ -301,6 +301,17 @@ static void otg_timer(unsigned long _musspin_unlock_irqrestore (&musb->lock, flags); } +void dsps_musb_clear_ep_rxintr (struct musb *musb,int epnum) +{ +u32 epintr; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +const struct dsps_musb_wrapper *wrp = glue->wrp; + +/* musb->lock might already been held */ + epintr = (1 << epnum) << wrp->rxep_shift; +musb_writel (musb->ctrl_base, wrp->epintr_status, epintr); +} +static irqreturn_t dsps_interrupt (int irq,void *hci) {struct musb *musb = hci;
@@ -647,6 +658,7 @@ static struct musb_platform_ops dsps_ops .try_idle = dsps_musb_try_idle, .set_mode = dsps_musb_set_mode, .recover = dsps_musb_recover, + .clear_ep_rxintr = dsps_musb_clear_ep_rxintr, };static u64 musb_dmamask =DMA_BIT_MASK (32 );
Greg Kroah-Hartman
maintainerPATCH 10/101 usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 674aea07e38200ea6f31ff6d5f200f0cf6cdb325 upstream.
This device gives the following error on detection. xhci_hcd 0000:00:11.0: ERROR Transfer event for disabled endpoint or incorrect stream ring
The same error is not seen when it is added to unusual_device list with US_FL_NO_REPORT_OPCODES passed.
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -2135,6 +2135,13 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), +/* Reported-by George Cherian <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x9561 ,0x0000 ,0x9999 , +"JMicron" , +"JMS56x" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , + US_FL_NO_REPORT_OPCODES), +/* * Patch by Constantin Baranov <[email protected]> * Report by Andreas Koenecke.
Greg Kroah-Hartman
maintainerPATCH 11/101 usb: gadgetfs: restrict upper bound on device configuration size
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 0994b0a257557e18ee8f0b7c5f0f73fe2b54eec1 upstream.
Andrey Konovalov reported that we were not properly checking the upper limit before of a device configuration size before calling memdup_user(), which could cause some problems.
So set the upper limit to PAGE_SIZE * 4, which should be good enough for all devices.
--- drivers/usb/gadget/legacy/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/inode.c +2 -1
@@ -1783,7 +1783,8 @@ dev_config (struct file *fd, const char }spin_unlock_irq (&dev->lock); -if (len < (USB_DT_CONFIG_SIZE +USB_DT_DEVICE_SIZE +4 )) +if ((len < (USB_DT_CONFIG_SIZE +USB_DT_DEVICE_SIZE +4 )) || + (len >PAGE_SIZE *4 ))return -EINVAL ;/* we might need to change message format someday */
Greg Kroah-Hartman
maintainerPATCH 12/101 USB: gadgetfs: fix unbounded memory allocation bug
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit faab50984fe6636e616c7cc3d30308ba391d36fd upstream.
Andrey Konovalov reports that fuzz testing with syzkaller causes a KASAN warning in gadgetfs:
BUG: KASAN: slab-out-of-bounds in dev_config+0x86f/0x1190 at addr ffff88003c47e160 Write of size 65537 by task syz-executor0/6356 CPU: 3 PID: 6356 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #19 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 ffff88003c107ad8 ffffffff81f96aba ffffffff3dc11ef0 1ffff10007820eee ffffed0007820ee6 ffff88003dc11f00 0000000041b58ab3 ffffffff8598b4c8 ffffffff81f96828 ffffffff813fb4a0 ffff88003b6eadc0 ffff88003c107738 Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff81f96aba>] dump_stack+0x292/0x398 lib/dump_stack.c:51 [<ffffffff817e4dec>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159 [< inline >] print_address_description mm/kasan/report.c:197 [<ffffffff817e5080>] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286 [<ffffffff817e5705>] kasan_report+0x35/0x40 mm/kasan/report.c:306 [< inline >] check_memory_region_inline mm/kasan/kasan.c:308 [<ffffffff817e3fb9>] check_memory_region+0x139/0x190 mm/kasan/kasan.c:315 [<ffffffff817e4044>] kasan_check_write+0x14/0x20 mm/kasan/kasan.c:326 [< inline >] copy_from_user arch/x86/include/asm/uaccess.h:689 [< inline >] ep0_write drivers/usb/gadget/legacy/inode.c:1135 [<ffffffff83228caf>] dev_config+0x86f/0x1190 drivers/usb/gadget/legacy/inode.c:1759 [<ffffffff817fdd55>] __vfs_write+0x5d5/0x760 fs/read_write.c:510 [<ffffffff817ff650>] vfs_write+0x170/0x4e0 fs/read_write.c:560 [< inline >] SYSC_write fs/read_write.c:607 [<ffffffff81803a5b>] SyS_write+0xfb/0x230 fs/read_write.c:599 [<ffffffff84f47ec1>] entry_SYSCALL_64_fastpath+0x1f/0xc2
Indeed, there is a comment saying that the value of len is restricted to a 16-bit integer, but the code doesn't actually do this.
This patch fixes the warning. It replaces the comment with a computation that forces the amount of data copied from the user in ep0_write() to be no larger than the wLength size for the control transfer, which is a 16-bit quantity.
--- drivers/usb/gadget/legacy/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/legacy/inode.c +1 -1
@@ -1125,7 +1125,7 @@ ep0_write (struct file *fd, const char _/* data and/or status stage for control request */ }else if (dev->state ==STATE_DEV_SETUP ) { -/* IN DATA+STATUS caller makes len <= wLength */ + len =min_t (size_t, len, dev->setup_wLength);if (dev->setup_in) { retval =setup_req (dev->gadget->ep0, dev->req, len);if (retval ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 13/101 USB: gadgetfs: fix use-after-free bug
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit add333a81a16abbd4f106266a2553677a165725f upstream.
Andrey Konovalov reports that fuzz testing with syzkaller causes a KASAN use-after-free bug report in gadgetfs:
BUG: KASAN: use-after-free in gadgetfs_setup+0x208a/0x20e0 at addr ffff88003dfe5bf2 Read of size 2 by task syz-executor0/22994 CPU: 3 PID: 22994 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #16 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 ffff88006df06a18 ffffffff81f96aba ffffffffe0528500 1ffff1000dbe0cd6 ffffed000dbe0cce ffff88006df068f0 0000000041b58ab3 ffffffff8598b4c8 ffffffff81f96828 1ffff1000dbe0ccd ffff88006df06708 ffff88006df06748 Call Trace: <IRQ> [ 201.343209] [< inline >] __dump_stack lib/dump_stack.c:15 <IRQ> [ 201.343209] [<ffffffff81f96aba>] dump_stack+0x292/0x398 lib/dump_stack.c:51 [<ffffffff817e4dec>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159 [< inline >] print_address_description mm/kasan/report.c:197 [<ffffffff817e5080>] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286 [< inline >] kasan_report mm/kasan/report.c:306 [<ffffffff817e562a>] __asan_report_load_n_noabort+0x3a/0x40 mm/kasan/report.c:337 [< inline >] config_buf drivers/usb/gadget/legacy/inode.c:1298 [<ffffffff8322c8fa>] gadgetfs_setup+0x208a/0x20e0 drivers/usb/gadget/legacy/inode.c:1368 [<ffffffff830fdcd0>] dummy_timer+0x11f0/0x36d0 drivers/usb/gadget/udc/dummy_hcd.c:1858 [<ffffffff814807c1>] call_timer_fn+0x241/0x800 kernel/time/timer.c:1308 [< inline >] expire_timers kernel/time/timer.c:1348 [<ffffffff81482de6>] __run_timers+0xa06/0xec0 kernel/time/timer.c:1641 [<ffffffff814832c1>] run_timer_softirq+0x21/0x80 kernel/time/timer.c:1654 [<ffffffff84f4af8b>] __do_softirq+0x2fb/0xb63 kernel/softirq.c:284
The cause of the bug is subtle. The dev_config() routine gets called twice by the fuzzer. The first time, the user data contains both a full-speed configuration descriptor and a high-speed config descriptor, causing dev->hs_config to be set. But it also contains an invalid device descriptor, so the buffer containing the descriptors is deallocated and dev_config() returns an error.
The second time dev_config() is called, the user data contains only a full-speed config descriptor. But dev->hs_config still has the stale pointer remaining from the first call, causing the routine to think that there is a valid high-speed config. Later on, when the driver dereferences the stale pointer to copy that descriptor, we get a use-after-free access.
The fix is simple: Clear dev->hs_config if the passed-in data does not contain a high-speed config descriptor.
--- drivers/usb/gadget/legacy/inode.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/legacy/inode.c +2 -0
@@ -1821,6 +1821,8 @@ dev_config (struct file *fd, const char goto fail; kbuf += total; length -= total; + }else { + dev->hs_config =NULL ; }/* could support multiple configs, using another encoding! */
Greg Kroah-Hartman
maintainerPATCH 14/101 USB: gadgetfs: fix checks of wTotalLength in config descriptors
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 1c069b057dcf64fada952eaa868d35f02bb0cfc2 upstream.
Andrey Konovalov's fuzz testing of gadgetfs showed that we should improve the driver's checks for valid configuration descriptors passed in by the user. In particular, the driver needs to verify that the wTotalLength value in the descriptor is not too short (smaller than USB_DT_CONFIG_SIZE). And the check for whether wTotalLength is too large has to be changed, because the driver assumes there is always enough room remaining in the buffer to hold a device descriptor (at least USB_DT_DEVICE_SIZE bytes).
This patch adds the additional check and fixes the existing check. It may do a little more than strictly necessary, but one extra check won't hurt.
--- drivers/usb/gadget/legacy/inode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/gadget/legacy/inode.c +7 -3
@@ -1755,10 +1755,12 @@ static struct usb_gadget_driver probe_dr* such as configuration notifications. */ -static int is_valid_config (struct usb_config_descriptor *config) +static int is_valid_config (struct usb_config_descriptor *config, +unsigned int total) {return config->bDescriptorType ==USB_DT_CONFIG && config->bLength ==USB_DT_CONFIG_SIZE + && total >=USB_DT_CONFIG_SIZE && config->bConfigurationValue !=0 && (config->bmAttributes &USB_CONFIG_ATT_ONE ) !=0 && (config->bmAttributes &USB_CONFIG_ATT_WAKEUP ) ==0 ;
@@ -1808,7 +1810,8 @@ dev_config (struct file *fd, const char/* full or low speed config */ dev->config = (void *) kbuf; total =le16_to_cpu (dev->config->wTotalLength); -if (!is_valid_config (dev->config) || total >= length) +if (!is_valid_config (dev->config, total) || + total > length -USB_DT_DEVICE_SIZE ) goto fail; kbuf += total; length -= total;
@@ -1817,7 +1820,8 @@ dev_config (struct file *fd, const charif (kbuf [1 ] ==USB_DT_CONFIG ) { dev->hs_config = (void *) kbuf; total =le16_to_cpu (dev->hs_config->wTotalLength); -if (!is_valid_config (dev->hs_config) || total >= length) +if (!is_valid_config (dev->hs_config, total) || + total > length -USB_DT_DEVICE_SIZE ) goto fail; kbuf += total; length -= total;
Greg Kroah-Hartman
maintainerPATCH 15/101 USB: fix problems with duplicate endpoint addresses
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 0a8fd1346254974c3a852338508e4a4cddbb35f1 upstream.
When checking a new device's descriptors, the USB core does not check for duplicate endpoint addresses. This can cause a problem when the sysfs files for those endpoints are created; trying to create multiple files with the same name will provoke a WARNING:
WARNING: CPU: 2 PID: 865 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x8a/0xa0 sysfs: cannot create duplicate filename '/devices/platform/dummy_hcd.0/usb2/2-1/2-1:64.0/ep_05' Kernel panic - not syncing: panic_on_warn set ... CPU: 2 PID: 865 Comm: kworker/2:1 Not tainted 4.9.0-rc7+ #34 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event ffff88006bee64c8 ffffffff81f96b8a ffffffff00000001 1ffff1000d7dcc2c ffffed000d7dcc24 0000000000000001 0000000041b58ab3 ffffffff8598b510 ffffffff81f968f8 ffffffff850fee20 ffffffff85cff020 dffffc0000000000 Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff81f96b8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51 [<ffffffff8168c88e>] panic+0x1cb/0x3a9 kernel/panic.c:179 [<ffffffff812b80b4>] __warn+0x1c4/0x1e0 kernel/panic.c:542 [<ffffffff812b8195>] warn_slowpath_fmt+0xc5/0x110 kernel/panic.c:565 [<ffffffff819e70ca>] sysfs_warn_dup+0x8a/0xa0 fs/sysfs/dir.c:30 [<ffffffff819e7308>] sysfs_create_dir_ns+0x178/0x1d0 fs/sysfs/dir.c:59 [< inline >] create_dir lib/kobject.c:71 [<ffffffff81fa1b07>] kobject_add_internal+0x227/0xa60 lib/kobject.c:229 [< inline >] kobject_add_varg lib/kobject.c:366 [<ffffffff81fa2479>] kobject_add+0x139/0x220 lib/kobject.c:411 [<ffffffff82737a63>] device_add+0x353/0x1660 drivers/base/core.c:1088 [<ffffffff82738d8d>] device_register+0x1d/0x20 drivers/base/core.c:1206 [<ffffffff82cb77d3>] usb_create_ep_devs+0x163/0x260 drivers/usb/core/endpoint.c:195 [<ffffffff82c9f27b>] create_intf_ep_devs+0x13b/0x200 drivers/usb/core/message.c:1030 [<ffffffff82ca39d3>] usb_set_configuration+0x1083/0x18d0 drivers/usb/core/message.c:1937 [<ffffffff82cc9e2e>] generic_probe+0x6e/0xe0 drivers/usb/core/generic.c:172 [<ffffffff82caa7fa>] usb_probe_device+0xaa/0xe0 drivers/usb/core/driver.c:263
This patch prevents the problem by checking for duplicate endpoint addresses during enumeration and skipping any duplicates.
--- drivers/usb/core/config.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/core/config.c +10 -0
@@ -205,6 +205,16 @@ static int usb_parse_endpoint(struct devif (ifp->desc.bNumEndpoints >= num_ep) goto skip_to_next_endpoint_or_interface_descriptor; +/* Check for duplicate endpoint addresses */ +for (i =0 ; i < ifp->desc.bNumEndpoints; ++i) { +if (ifp->endpoint[i].desc.bEndpointAddress == + d->bEndpointAddress) { +dev_warn (ddev,"config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n" , + cfgno, inum, asnum, d->bEndpointAddress); + goto skip_to_next_endpoint_or_interface_descriptor; + } + } + endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints;
Greg Kroah-Hartman
maintainerPATCH 16/101 USB: dummy-hcd: fix bug in stop_activity (handle ep0)
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit bcdbeb844773333d2d1c08004f3b3e25921040e5 upstream.
The stop_activity() routine in dummy-hcd is supposed to unlink all active requests for every endpoint, among other things. But it doesn't handle ep0. As a result, fuzz testing can generate a WARNING like the following:
WARNING: CPU: 0 PID: 4410 at drivers/usb/gadget/udc/dummy_hcd.c:672 dummy_free_request+0x153/0x170 Modules linked in: CPU: 0 PID: 4410 Comm: syz-executor Not tainted 4.9.0-rc7+ #32 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 ffff88006a64ed10 ffffffff81f96b8a ffffffff41b58ab3 1ffff1000d4c9d35 ffffed000d4c9d2d ffff880065f8ac00 0000000041b58ab3 ffffffff8598b510 ffffffff81f968f8 0000000041b58ab3 ffffffff859410e0 ffffffff813f0590 Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff81f96b8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51 [<ffffffff812b808f>] __warn+0x19f/0x1e0 kernel/panic.c:550 [<ffffffff812b831c>] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585 [<ffffffff830fcb13>] dummy_free_request+0x153/0x170 drivers/usb/gadget/udc/dummy_hcd.c:672 [<ffffffff830ed1b0>] usb_ep_free_request+0xc0/0x420 drivers/usb/gadget/udc/core.c:195 [<ffffffff83225031>] gadgetfs_unbind+0x131/0x190 drivers/usb/gadget/legacy/inode.c:1612 [<ffffffff830ebd8f>] usb_gadget_remove_driver+0x10f/0x2b0 drivers/usb/gadget/udc/core.c:1228 [<ffffffff830ec084>] usb_gadget_unregister_driver+0x154/0x240 drivers/usb/gadget/udc/core.c:1357
This patch fixes the problem by iterating over all the endpoints in the driver's ep array instead of iterating over the gadget's ep_list, which explicitly leaves out ep0.
--- drivers/usb/gadget/udc/dummy_hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/dummy_hcd.c +3 -3
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, stru/* caller must hold lock */ static void stop_activity (struct dummy *dum) { -struct dummy_ep *ep; +int i;/* prevent any more requests */ dum->address =0 ;
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy */* The timer is left running so that outstanding URBs can fail */ /* nuke any pending requests first, so driver i/o is quiesced */ -list_for_each_entry (ep, &dum->gadget.ep_list, ep.ep_list) -nuke (dum, ep); +for (i =0 ; i <DUMMY_ENDPOINTS ; ++i) +nuke (dum, &dum->ep[i]);/* driver now does any non-usb quiescing necessary */ }
Greg Kroah-Hartman
maintainerPATCH 17/101 usb: gadget: composite: Test get_alt() presence instead of set_alt()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Opasiak <[email protected]>
commit 7e4da3fcf7c9fe042f2f7cb7bf23861a899b4a8f upstream.
By convention (according to doc) if function does not provide get_alt() callback composite framework should assume that it has only altsetting 0 and should respond with error if host tries to set other one.
After commit dd4dff8b035f ("USB: composite: Fix bug: should test set_alt function pointer before use it")
we started checking set_alt() callback instead of get_alt(). This check is useless as we check if set_alt() is set inside usb_add_function() and fail if it's NULL.
Let's fix this check and move comment about why we check the get method instead of set a little bit closer to prevent future false fixes.
--- drivers/usb/gadget/composite.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/usb/gadget/composite.c +8 -4
@@ -1601,9 +1601,7 @@ composite_setup(struct usb_gadget *gadge value =min (w_length, (u16 )1 );break ; -/* function drivers must handle get/set altsetting; if there's -* no get() method, we know only altsetting zero works. -*/ +/* function drivers must handle get/set altsetting */ case USB_REQ_SET_INTERFACE :if (ctrl->bRequestType !=USB_RECIP_INTERFACE ) goto unknown;
@@ -1612,7 +1610,13 @@ composite_setup(struct usb_gadget *gadge f = cdev->config->interface[intf];if (!f)break ; -if (w_value && !f->set_alt) + +/* +* If there's no get_alt() method, we know only altsetting zero +* works. There is no need to check if set_alt() is not NULL +* as we check this in usb_add_function(). +*/ +if (w_value && !f->get_alt)break ; value = f->set_alt (f, w_index, w_value);if (value ==USB_GADGET_DELAYED_STATUS ) {
Greg Kroah-Hartman
maintainerPATCH 18/101 usb: dwc3: core: avoid Overflow events
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit e71d363d9c611c99fb78f53bfee99616e7fe352c upstream.
Now that we're handling so many transfers at a time and for some dwc3 revisions LPM events *must* be enabled, we can fall into a situation where too many events fire and we start receiving Overflow events.
Let's do what XHCI does and allocate a full page for the Event Ring, this will avoid any future issues.
--- drivers/usb/dwc3/core.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/dwc3/core.h +1 -3
@@ -42,9 +42,7 @@#define DWC3_XHCI_RESOURCES_NUM 2#define DWC3_SCRATCHBUF_SIZE 4096/* each buffer is assumed to be 4KiB */ -#define DWC3_EVENT_SIZE 4/* bytes */ -#define DWC3_EVENT_MAX_NUM 64/* 2 events/endpoint */ -#define DWC3_EVENT_BUFFERS_SIZE (DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM) +#define DWC3_EVENT_BUFFERS_SIZE 4096#define DWC3_EVENT_TYPE_MASK 0xfe#define DWC3_EVENT_TYPE_DEV 0
Greg Kroah-Hartman
maintainerPATCH 19/101 usb: xhci: fix possible wild pointer
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 2b985467371a58ae44d76c7ba12b0951fee6ed98 upstream.
handle_cmd_completion() frees a command structure which might be still referenced by xhci->current_cmd.
This might cause problem when xhci->current_cmd is accessed after that.
A real-life case could be like this. The host takes a very long time to respond to a command, and the command timer is fired at the same time when the command completion event arrives. The command completion handler frees xhci->current_cmd before the timer function can grab xhci->lock. Afterward, timer function grabs the lock and go ahead with checking and setting members of xhci->current_cmd.
--- drivers/usb/host/xhci-ring.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-ring.c +11 -5
@@ -1268,14 +1268,18 @@ void xhci_handle_command_timeout(unsignebool second_timeout = false; xhci = (struct xhci_hcd *) data; -/* mark this command to be cancelled */ spin_lock_irqsave (&xhci->lock, flags); -if (xhci->current_cmd) { -if (xhci->current_cmd->status ==COMP_CMD_ABORT ) - second_timeout = true; - xhci->current_cmd->status =COMP_CMD_ABORT ; + +if (!xhci->current_cmd) { +spin_unlock_irqrestore (&xhci->lock, flags); +return ; } +/* mark this command to be cancelled */ +if (xhci->current_cmd->status ==COMP_CMD_ABORT ) + second_timeout = true; + xhci->current_cmd->status =COMP_CMD_ABORT ; +/* Make sure command ring is running before aborting it */ hw_ring_state =xhci_read_64 (xhci, &xhci->op_regs->cmd_ring); if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
@@ -1424,6 +1428,8 @@ static void handle_cmd_completion(struct xhci->current_cmd =list_entry (cmd->cmd_list.next, struct xhci_command, cmd_list);mod_timer (&xhci->cmd_timer, jiffies +XHCI_CMD_DEFAULT_TIMEOUT ); + }else if (xhci->current_cmd == cmd) { + xhci->current_cmd =NULL ; } event_handled:
Greg Kroah-Hartman
maintainerPATCH 20/101 xhci: workaround for hosts missing CAS bit
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 346e99736c3ce328fd42d678343b70243aca5f36 upstream.
If a device is unplugged and replugged during Sx system suspend some Intel xHC hosts will overwrite the CAS (Cold attach status) flag and no device connection is noticed in resume.
A device in this state can be identified in resume if its link state is in polling or compliance mode, and the current connect status is 0. A device in this state needs to be warm reset.
Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8
Observed on Cherryview and Apollolake as they go into compliance mode if LFPS times out during polling, and re-plugged devices are not discovered at resume.
--- drivers/usb/host/xhci-hub.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/usb/host/xhci-pci.c | 6 ++++++ drivers/usb/host/xhci.h | 3 +++ 3 files changed, 46 insertions(+)
drivers/usb/host/xhci-hub.c +37 -0
@@ -1346,6 +1346,35 @@ int xhci_bus_suspend(struct usb_hcd *hcdreturn 0 ; } +/* +* Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3. +* warm reset a USB3 device stuck in polling or compliance mode after resume. +* See Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8 +*/ +static bool xhci_port_missing_cas_quirk (int port_index, +__le32 __iomem **port_array) +{ +u32 portsc; + + portsc =readl (port_array[port_index]); + +/* if any of these are set we are not stuck */ +if (portsc & (PORT_CONNECT |PORT_CAS )) +return false; + +if (((portsc &PORT_PLS_MASK ) !=XDEV_POLLING ) && + ((portsc &PORT_PLS_MASK ) !=XDEV_COMP_MODE )) +return false; + +/* clear wakeup/change bits, and do a warm port reset */ + portsc &= ~(PORT_RWC_BITS |PORT_CEC |PORT_WAKE_BITS ); + portsc |=PORT_WR ; +writel (portsc, port_array[port_index]); +/* flush write */ +readl (port_array[port_index]); +return true; +} +int xhci_bus_resume (struct usb_hcd *hcd) {struct xhci_hcd *xhci =hcd_to_xhci (hcd);
@@ -1383,6 +1412,14 @@ int xhci_bus_resume(struct usb_hcd *hcd)u32 temp; temp =readl (port_array[port_index]); + +/* warm reset CAS limited ports stuck in polling/compliance */ +if ((xhci->quirks &XHCI_MISSING_CAS ) && + (hcd->speed >=HCD_USB3 ) && +xhci_port_missing_cas_quirk (port_index, port_array)) { +xhci_dbg (xhci,"reset stuck port %d\n" , port_index); +continue ; + }if (DEV_SUPERSPEED_ANY (temp)) temp &= ~(PORT_RWC_BITS |PORT_CEC |PORT_WAKE_BITS );else
drivers/usb/host/xhci-pci.c +6 -0
@@ -51,6 +51,7 @@#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 +#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8static const char hcd_name[] ="xhci_hcd" ;
@@ -168,6 +169,11 @@ static void xhci_pci_quirks(struct devic pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { xhci->quirks |=XHCI_PME_STUCK_QUIRK ; } +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + (pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || + pdev->device ==PCI_DEVICE_ID_INTEL_APL_XHCI )) + xhci->quirks |=XHCI_MISSING_CAS ; +if (pdev->vendor ==PCI_VENDOR_ID_ETRON && pdev->device ==PCI_DEVICE_ID_EJ168 ) { xhci->quirks |=XHCI_RESET_ON_RESUME ;
drivers/usb/host/xhci.h +3 -0
@@ -312,6 +312,8 @@ struct xhci_op_regs {#define XDEV_U2 (0x2 << 5)#define XDEV_U3 (0x3 << 5)#define XDEV_INACTIVE (0x6 << 5) +#define XDEV_POLLING (0x7 << 5) +#define XDEV_COMP_MODE (0xa << 5)#define XDEV_RESUME (0xf << 5)/* true: port has power (see HCC_PPC) */ #define PORT_POWER (1 << 9)
@@ -1631,6 +1633,7 @@ struct xhci_hcd {/* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS (1 << 19)#define XHCI_PME_STUCK_QUIRK (1 << 20) +#define XHCI_MISSING_CAS (1 << 24)unsigned int num_active_eps;unsigned int limit_active_eps;/* There are two roothubs to keep track of bus suspend info for */
Greg Kroah-Hartman
maintainerPATCH 21/101 usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wan Ahmad Zainie <[email protected]>
commit 6c97cfc1a097b1e0786c836e92b7a72b4d031e25 upstream.
Intel Apollo Lake also requires XHCI_PME_STUCK_QUIRK. Adding its PCI ID to quirk.
--- drivers/usb/host/xhci-pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +2 -1
@@ -166,7 +166,8 @@ static void xhci_pci_quirks(struct devic pdev->device ==PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { + pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) { xhci->quirks |= XHCI_PME_STUCK_QUIRK; } if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
Greg Kroah-Hartman
maintainerPATCH 22/101 xhci: free xhci virtual devices with leaf nodes first
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit ee8665e28e8d90ce69d4abe5a469c14a8707ae0e upstream.
the tt_info provided by a HS hub might be in use to by a child device Make sure we free the devices in the correct order.
This is needed in special cases such as when xhci controller is reset when resuming from hibernate, and all virt_devices are freed.
Also free the virt_devices starting from max slot_id as children more commonly have higher slot_id than parent.
--- drivers/usb/host/xhci-mem.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-mem.c +36 -2
@@ -964,6 +964,40 @@ void xhci_free_virt_device(struct xhci_h xhci->devs[slot_id] =NULL ; } +/* +* Free a virt_device structure. +* If the virt_device added a tt_info (a hub) and has children pointing to +* that tt_info, then free the child first. Recursive. +* We can't rely on udev at this point to find child-parent relationships. +*/ +void xhci_free_virt_devices_depth_first (struct xhci_hcd *xhci,int slot_id) +{ +struct xhci_virt_device *vdev; +struct list_head *tt_list_head; +struct xhci_tt_bw_info *tt_info, *next; +int i; + + vdev = xhci->devs[slot_id]; +if (!vdev) +return ; + + tt_list_head = &(xhci->rh_bw[vdev->real_port -1 ].tts); +list_for_each_entry_safe (tt_info, next, tt_list_head, tt_list) { +/* is this a hub device that added a tt_info to the tts list */ +if (tt_info->slot_id == slot_id) { +/* are any devices using this tt_info? */ +for (i =1 ; i <HCS_MAX_SLOTS (xhci->hcs_params1); i++) { + vdev = xhci->devs[i]; +if (vdev && (vdev->tt_info == tt_info)) +xhci_free_virt_devices_depth_first ( + xhci, i); + } + } + } +/* we are now at a leaf device */ +xhci_free_virt_device (xhci, slot_id); +} +int xhci_alloc_virt_device (struct xhci_hcd *xhci,int slot_id,struct usb_device *udev,gfp_t flags) {
@@ -1828,8 +1862,8 @@ void xhci_mem_cleanup(struct xhci_hcd *x } } -for (i =1 ; i <MAX_HC_SLOTS ; ++i) -xhci_free_virt_device (xhci, i); +for (i =HCS_MAX_SLOTS (xhci->hcs_params1); i >0 ; i--) +xhci_free_virt_devices_depth_first (xhci, i);dma_pool_destroy (xhci->segment_pool); xhci->segment_pool =NULL ;
Greg Kroah-Hartman
maintainerPATCH 23/101 usb: xhci: fix return value of xhci_setup_device()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 90797aee5d6902b49a453c97d83c326408aeb5a8 upstream.
xhci_setup_device() should return failure with correct error number when xhci host has died, removed or halted.
During usb device enumeration, if usb host is not accessible (died, removed or halted), the hc_driver->address_device() should return a corresponding error code to usb core. But current xhci driver just returns success. This misleads usb core to continue the enumeration by reading the device descriptor, which will result in failure, and users will get a misleading message like "device descriptor read/8, error -110".
--- drivers/usb/host/xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +3 -1
@@ -3808,8 +3808,10 @@ static int xhci_setup_device(struct usb_mutex_lock (&xhci->mutex); -if (xhci->xhc_state)/* dying, removing or halted */ +if (xhci->xhc_state) {/* dying, removing or halted */ + ret = -ESHUTDOWN ; goto out; + }if (!udev->slot_id) { xhci_dbg_trace(xhci, trace_xhci_dbg_address,
Greg Kroah-Hartman
maintainerPATCH 24/101 usb: host: xhci: Fix possible wild pointer when handling abort command
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baolin Wang <[email protected]>
commit 2a7cfdf37b7c08ac29df4c62ea5ccb01474b6597 upstream.
When current command was supposed to be aborted, host will free the command in handle_cmd_completion() function. But it might be still referenced by xhci->current_cmd, which need to set NULL.
--- drivers/usb/host/xhci-ring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-ring.c +4 -1
@@ -1365,8 +1365,11 @@ static void handle_cmd_completion(struct*/ if (cmd_comp_code ==COMP_CMD_ABORT ) { xhci->cmd_ring_state =CMD_RING_STATE_STOPPED ; -if (cmd->status ==COMP_CMD_ABORT ) +if (cmd->status ==COMP_CMD_ABORT ) { +if (xhci->current_cmd == cmd) + xhci->current_cmd =NULL ; goto event_handled; + } } cmd_type =TRB_FIELD_TO_TYPE (le32_to_cpu (cmd_trb->generic.field[3 ]));
Greg Kroah-Hartman
maintainerPATCH 25/101 xhci: Handle command completion and timeout race
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit a5a1b9514154437aa1ed35c291191f82fd3e941a upstream.
If we get a command completion event at the same time as the command timeout work starts on another cpu we might end up aborting the wrong command.
If the command completion takes the xhci lock before the timeout work, it will handle the command, pick the next command, mark it as current_cmd, and re-queue the timeout work. When the timeout work finally gets the lock It will start aborting the wrong command.
This case can be resolved by checking if the timeout work is pending inside the timeout function itself. A new timeout work can only be pending if the command completed and a new command was queued.
If there are no more commands pending then command completion will set the current_cmd to NULL, which is already handled in the timeout work.
--- drivers/usb/host/xhci-ring.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-ring.c +5 -1
@@ -1270,7 +1270,11 @@ void xhci_handle_command_timeout(unsignespin_lock_irqsave (&xhci->lock, flags); -if (!xhci->current_cmd) { +/* +* If timeout work is pending, or current_cmd is NULL, it means we +* raced with command completion. Command is handled so just return. +*/ +if (!xhci->current_cmd ||timer_pending (&xhci->cmd_timer)) {spin_unlock_irqrestore (&xhci->lock, flags);return ; }
Greg Kroah-Hartman
maintainerPATCH 26/101 usb: xhci: hold lock over xhci_abort_cmd_ring()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 4dea70778c0f48b4385c7720c363ec8d37a401b4 upstream.
In command timer function, xhci_handle_command_timeout(), xhci->lock is unlocked before call into xhci_abort_cmd_ring(). This might cause race between the timer function and the event handler.
The xhci_abort_cmd_ring() function sets the CMD_RING_ABORT bit in the command register and polling it until the setting takes effect. A stop command ring event might be handled between writing the abort bit and polling for it. The event handler will restart the command ring, which causes the failure of polling, and we ever believed that we failed to stop it.
As a bonus, this also fixes some issues of calling functions without locking in xhci_handle_command_timeout().
--- drivers/usb/host/xhci-ring.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +9 -4
@@ -1288,29 +1288,34 @@ void xhci_handle_command_timeout(unsigne hw_ring_state =xhci_read_64 (xhci, &xhci->op_regs->cmd_ring);if ((xhci->cmd_ring_state &CMD_RING_STATE_RUNNING ) && (hw_ring_state &CMD_RING_RUNNING )) { -spin_unlock_irqrestore (&xhci->lock, flags);xhci_dbg (xhci,"Command timeout\n" ); ret =xhci_abort_cmd_ring (xhci);if (unlikely (ret == -ESHUTDOWN )) {xhci_err (xhci,"Abort command ring failed\n" );xhci_cleanup_command_queue (xhci); +spin_unlock_irqrestore (&xhci->lock, flags);usb_hc_died (xhci_to_hcd (xhci)->primary_hcd);xhci_dbg (xhci,"xHCI host controller is dead.\n" ); + +return ; } -return ; + + goto time_out_completed; }/* command ring failed to restart, or host removed. Bail out */ if (second_timeout || xhci->xhc_state &XHCI_STATE_REMOVING ) { -spin_unlock_irqrestore (&xhci->lock, flags);xhci_dbg (xhci,"command timed out twice, ring start fail?\n" );xhci_cleanup_command_queue (xhci); -return ; + + goto time_out_completed; }/* command timeout on stopped ring, ring can't be aborted */ xhci_dbg (xhci,"Command timeout on stopped ring\n" );xhci_handle_stopped_cmd_ring (xhci, xhci->current_cmd); + +time_out_completed:spin_unlock_irqrestore (&xhci->lock, flags);return ; }
Greg Kroah-Hartman
maintainerPATCH 27/101 USB: serial: omninet: fix NULL-derefs at open and disconnect
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a5bc01949e3b19d8a23b5eabc6fc71bb50dc820e upstream.
Fix NULL-pointer dereferences at open() and disconnect() should the device lack the expected bulk-out endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 000000b4
...
[c0170ff0>] (__lock_acquire) from [<c0172f00>] (lock_acquire+0x108/0x264) [<c0172f00>] (lock_acquire) from [<c06a5090>] (_raw_spin_lock_irqsave+0x58/0x6c) [<c06a5090>] (_raw_spin_lock_irqsave) from [<c0470684>] (tty_port_tty_set+0x28/0xa4) [<c0470684>] (tty_port_tty_set) from [<bf08d384>] (omninet_open+0x30/0x40 [omninet]) [<bf08d384>] (omninet_open [omninet]) from [<bf07c118>] (serial_port_activate+0x68/0x98 [usbserial])
Unable to handle kernel NULL pointer dereference at virtual address 00000234
...
[<bf01f418>] (omninet_disconnect [omninet]) from [<bf0016c0>] (usb_serial_disconnect+0xe4/0x100 [usbserial])
--- drivers/usb/serial/omninet.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/usb/serial/omninet.c +13 -0
@@ -38,6 +38,7 @@ static int omninet_write(struct tty_str const unsigned char *buf, int count);static int omninet_write_room (struct tty_struct *tty);static void omninet_disconnect (struct usb_serial *serial); +static int omninet_attach (struct usb_serial *serial);static int omninet_port_probe (struct usb_serial_port *port);static int omninet_port_remove (struct usb_serial_port *port);
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_om .description = "ZyXEL - omni.net lcd plus usb", .id_table = id_table, .num_ports = 1, + .attach = omninet_attach, .port_probe = omninet_port_probe, .port_remove = omninet_port_remove, .open = omninet_open,
@@ -104,6 +106,17 @@ struct omninet_data {__u8 od_outseq;/* Sequence number for bulk_out URBs */ }; +static int omninet_attach (struct usb_serial *serial) +{ +/* The second bulk-out endpoint is used for writing. */ +if (serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int omninet_port_probe (struct usb_serial_port *port) {struct omninet_data *od;
Greg Kroah-Hartman
maintainerPATCH 28/101 USB: serial: quatech2: fix sleep-while-atomic in close
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit f09d1886a41e9063b43da493ef0e845ac8afd2fa upstream.
The write URB was being killed using the synchronous interface while holding a spin lock in close().
Simply drop the lock and busy-flag update, something which would have been taken care of by the completion handler if the URB was in flight.
--- drivers/usb/serial/quatech2.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/usb/serial/quatech2.c +0 -4
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_ {struct usb_serial *serial;struct qt2_port_private *port_priv; -unsigned long flags;int i; serial = port->serial; port_priv =usb_get_serial_port_data (port); -spin_lock_irqsave (&port_priv->urb_lock, flags);usb_kill_urb (port_priv->write_urb); - port_priv->urb_in_use = false; -spin_unlock_irqrestore (&port_priv->urb_lock, flags);/* flush the port transmit buffer */ i = usb_control_msg(serial->dev,
Greg Kroah-Hartman
maintainerPATCH 29/101 USB: serial: pl2303: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 76ab439ed1b68778e9059c79ecc5d14de76c89a8 upstream.
Fix NULL-pointer dereference in open() should a type-0 or type-1 device lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at pl2303_open+0x38/0xec [pl2303]
Note that a missing interrupt-in endpoint would have caused open() to fail.
--- drivers/usb/serial/pl2303.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/pl2303.c +8 -0
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_seriastatic int pl2303_startup (struct usb_serial *serial) {struct pl2303_serial_private *spriv; +unsigned char num_ports = serial->num_ports;enum pl2303_type type =TYPE_01 ;unsigned char *buf; +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + spriv =kzalloc (sizeof (*spriv),GFP_KERNEL );if (!spriv)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 30/101 USB: serial: keyspan_pda: verify endpoints at probe
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5d9b0f859babe96175cd33d7162a9463a875ffde upstream.
Check for the expected endpoints in attach() and fail loudly if not present.
Note that failing to do this appears to be benign since da280e348866 ("USB: keyspan_pda: clean up write-urb busy handling") which prevents a NULL-pointer dereference in write() by never marking a non-existent write-urb as free.
--- drivers/usb/serial/keyspan_pda.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/serial/keyspan_pda.c +14 -0
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pdaMODULE_FIRMWARE ("keyspan_pda/xircom_pgs.fw" );#endif +static int keyspan_pda_attach (struct usb_serial *serial) +{ +unsigned char num_ports = serial->num_ports; + +if (serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int keyspan_pda_port_probe (struct usb_serial_port *port) {
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_ .break_ctl = keyspan_pda_break_ctl, .tiocmget = keyspan_pda_tiocmget, .tiocmset = keyspan_pda_tiocmset, + .attach = keyspan_pda_attach, .port_probe = keyspan_pda_port_probe, .port_remove = keyspan_pda_port_remove, };
Greg Kroah-Hartman
maintainerPATCH 31/101 USB: serial: spcp8x5: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cc0909248258f679c4bb4cd315565d40abaf6bc6 upstream.
Fix NULL-pointer dereference in open() should the device lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at spcp8x5_open+0x30/0xd0 [spcp8x5]
--- drivers/usb/serial/spcp8x5.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/serial/spcp8x5.c +14 -0
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serireturn 0 ; } +static int spcp8x5_attach (struct usb_serial *serial) +{ +unsigned char num_ports = serial->num_ports; + +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int spcp8x5_port_probe (struct usb_serial_port *port) {const struct usb_device_id *id =usb_get_serial_data (port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_ .tiocmget = spcp8x5_tiocmget, .tiocmset = spcp8x5_tiocmset, .probe = spcp8x5_probe, + .attach = spcp8x5_attach, .port_probe = spcp8x5_port_probe, .port_remove = spcp8x5_port_remove, };
Greg Kroah-Hartman
maintainerPATCH 32/101 USB: serial: io_ti: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a323fefc6f5079844dc62ffeb54f491d0242ca35 upstream.
Fix NULL-pointer dereference when clearing halt at open should a malicious device lack the expected endpoints when in download mode.
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf011ed8>] (edge_open [io_ti]) from [<bf000118>] (serial_port_activate+0x68/0x98 [usbserial]) [<bf000118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8) [<c0470ca4>] (tty_port_open) from [<bf000da0>] (serial_open+0x48/0x6c [usbserial]) [<bf000da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
--- drivers/usb/serial/io_ti.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/serial/io_ti.c +7 -0
@@ -2549,6 +2549,13 @@ static int edge_startup(struct usb_seriaint status;u16 product_id; +/* Make sure we have the required endpoints when in download mode. */ +if (serial->interface->cur_altsetting->desc.bNumEndpoints >1 ) { +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) +return -ENODEV ; + } +/* create our private serial structure */ edge_serial =kzalloc (sizeof (struct edgeport_serial ),GFP_KERNEL );if (!edge_serial)
Greg Kroah-Hartman
maintainerPATCH 33/101 USB: serial: io_ti: fix another NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 4f9785cc99feeb3673993b471f646b4dbaec2cc1 upstream.
In case a device is left in "boot-mode" we must not register any port devices in order to avoid a NULL-pointer dereference on open due to missing endpoints. This could be used by a malicious device to trigger an OOPS:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf0caa84>] (edge_open [io_ti]) from [<bf0b0118>] (serial_port_activate+0x68/0x98 [usbserial]) [<bf0b0118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8) [<c0470ca4>] (tty_port_open) from [<bf0b0da0>] (serial_open+0x48/0x6c [usbserial]) [<bf0b0da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
--- drivers/usb/serial/io_ti.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/serial/io_ti.c +6 -3
@@ -1508,7 +1508,7 @@ stayinbootmode:dev_dbg (dev,"%s - STAYING IN BOOT MODE\n" , __func__); serial->product_info.TiMode =TI_MODE_BOOT ; -return 0 ; +return 1 ; }static int ti_do_config (struct edgeport_port *port,int feature,int on)
@@ -2563,14 +2563,18 @@ static int edge_startup(struct usb_seriamutex_init (&edge_serial->es_lock); edge_serial->serial = serial; +INIT_DELAYED_WORK (&edge_serial->heartbeat_work, edge_heartbeat_work);usb_set_serial_data (serial, edge_serial); status =download_fw (edge_serial); -if (status) { +if (status <0 ) {kfree (edge_serial);return status; } +if (status >0 ) +return 1 ;/* bind but do not register any ports */ + product_id =le16_to_cpu ( edge_serial->serial->dev->descriptor.idProduct);
@@ -2582,7 +2586,6 @@ static int edge_startup(struct usb_seria } } -INIT_DELAYED_WORK (&edge_serial->heartbeat_work, edge_heartbeat_work);edge_heartbeat_schedule (edge_serial);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 34/101 USB: serial: io_ti: fix I/O after disconnect
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 2330d0a853da260d8a9834a70df448032b9ff623 upstream.
Cancel the heartbeat work on driver unbind in order to avoid I/O after disconnect in case the port is held open.
Note that the cancel in release() is still needed to stop the heartbeat after late probe errors.
--- drivers/usb/serial/io_ti.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/io_ti.c +3 -0
@@ -2593,6 +2593,9 @@ static int edge_startup(struct usb_seriastatic void edge_disconnect (struct usb_serial *serial) { +struct edgeport_serial *edge_serial =usb_get_serial_data (serial); + +cancel_delayed_work_sync (&edge_serial->heartbeat_work); }static void edge_release (struct usb_serial *serial)
Greg Kroah-Hartman
maintainerPATCH 35/101 USB: serial: iuu_phoenix: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 90507d54f712d81b74815ef3a4bbb555cd9fab2f upstream.
Fix NULL-pointer dereference at open should the device lack a bulk-in or bulk-out endpoint:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at iuu_open+0x78/0x59c [iuu_phoenix]
check")
--- drivers/usb/serial/iuu_phoenix.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/serial/iuu_phoenix.c +11 -0
@@ -68,6 +68,16 @@ struct iuu_private {u32 clk; }; +static int iuu_attach (struct usb_serial *serial) +{ +unsigned char num_ports = serial->num_ports; + +if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports) +return -ENODEV ; + +return 0 ; +} +static int iuu_port_probe (struct usb_serial_port *port) {struct iuu_private *priv;
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_devi .tiocmset = iuu_tiocmset, .set_termios = iuu_set_termios, .init_termios = iuu_init_termios, + .attach = iuu_attach, .port_probe = iuu_port_probe, .port_remove = iuu_port_remove, };
Greg Kroah-Hartman
maintainerPATCH 36/101 USB: serial: garmin_gps: fix memory leak on failed URB submit
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c4ac4496e835b78a45dfbf74f6173932217e4116 upstream.
Make sure to free the URB transfer buffer in case submission fails (e.g. due to a disconnect).
--- drivers/usb/serial/garmin_gps.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/garmin_gps.c +1 -0
@@ -1044,6 +1044,7 @@ static int garmin_write_bulk(struct usb_"%s - usb_submit_urb(write bulk) failed with status = %d\n" , __func__, status); count = status; +kfree (buffer); }/* we are done with this urb, so let the host driver
Greg Kroah-Hartman
maintainerPATCH 37/101 USB: serial: ti_usb_3410_5052: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ef079936d3cd09e63612834fe2698eeada0d8e3f upstream.
Fix NULL-pointer dereference in open() should a malicious device lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
..
[<bf06a6b0>] (ti_open [ti_usb_3410_5052]) from [<bf02e118>] (serial_port_activate+0x68/0x98 [usbserial])
--- drivers/usb/serial/ti_usb_3410_5052.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/serial/ti_usb_3410_5052.c +7 -0
@@ -339,6 +339,13 @@ static int ti_startup(struct usb_serial goto free_tdev; } +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); + status = -ENODEV ; + goto free_tdev; + } +return 0 ; free_tdev:
Greg Kroah-Hartman
maintainerPATCH 38/101 USB: serial: io_edgeport: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0dd408425eb21ddf26a692b3c8044c9e7d1a7948 upstream.
Fix NULL-pointer dereference when initialising URBs at open should a non-EPIC device lack a bulk-in or interrupt-in endpoint.
Unable to handle kernel NULL pointer dereference at virtual address 00000028
...
PC is at edge_open+0x24c/0x3e8 [io_edgeport]
Note that the EPIC-device probe path has the required sanity checks so this makes those checks partially redundant.
--- drivers/usb/serial/io_edgeport.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/io_edgeport.c +5 -0
@@ -2761,6 +2761,11 @@ static int edge_startup(struct usb_seriaEDGE_COMPATIBILITY_MASK1 , EDGE_COMPATIBILITY_MASK2 }; +if (serial->num_bulk_in <1 || serial->num_interrupt_in <1 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + dev = serial->dev;/* create our private serial structure */
Greg Kroah-Hartman
maintainerPATCH 39/101 USB: serial: oti6858: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5afeef2366db14587b65558bbfd5a067542e07fb upstream.
Fix NULL-pointer dereference in open() should the device lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at oti6858_open+0x30/0x1d0 [oti6858]
Note that a missing interrupt-in endpoint would have caused open() to fail.
cable)")
--- drivers/usb/serial/oti6858.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/serial/oti6858.c +16 -0
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(strucstatic int oti6858_tiocmget (struct tty_struct *tty);static int oti6858_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear); +static int oti6858_attach (struct usb_serial *serial);static int oti6858_port_probe (struct usb_serial_port *port);static int oti6858_port_remove (struct usb_serial_port *port);
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_ .write_bulk_callback = oti6858_write_bulk_callback, .write_room = oti6858_write_room, .chars_in_buffer = oti6858_chars_in_buffer, + .attach = oti6858_attach, .port_probe = oti6858_port_probe, .port_remove = oti6858_port_remove, };
@@ -324,6 +326,20 @@ static void send_data(struct work_structusb_serial_port_softint (port); } +static int oti6858_attach (struct usb_serial *serial) +{ +unsigned char num_ports = serial->num_ports; + +if (serial->num_bulk_in < num_ports || + serial->num_bulk_out < num_ports || + serial->num_interrupt_in < num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int oti6858_port_probe (struct usb_serial_port *port) {struct oti6858_private *priv;
Greg Kroah-Hartman
maintainerPATCH 40/101 USB: serial: cyberjack: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3dca01114dcecb1cf324534cd8d75fd1306a516b upstream.
Fix NULL-pointer dereference when clearing halt at open should the device lack a bulk-out endpoint.
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at cyberjack_open+0x40/0x9c [cyberjack]
--- drivers/usb/serial/cyberjack.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/serial/cyberjack.c +10 -0
@@ -50,6 +50,7 @@#define CYBERJACK_PRODUCT_ID 0x0100/* Function prototypes */ +static int cyberjack_attach (struct usb_serial *serial);static int cyberjack_port_probe (struct usb_serial_port *port);static int cyberjack_port_remove (struct usb_serial_port *port); static int cyberjack_open(struct tty_struct *tty,
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjac .description = "Reiner SCT Cyberjack USB card reader", .id_table = id_table, .num_ports = 1, + .attach = cyberjack_attach, .port_probe = cyberjack_port_probe, .port_remove = cyberjack_port_remove, .open = cyberjack_open,
@@ -100,6 +102,14 @@ struct cyberjack_private {short wrsent;/* Data already sent */ }; +static int cyberjack_attach (struct usb_serial *serial) +{ +if (serial->num_bulk_out < serial->num_ports) +return -ENODEV ; + +return 0 ; +} +static int cyberjack_port_probe (struct usb_serial_port *port) {struct cyberjack_private *priv;
Greg Kroah-Hartman
maintainerPATCH 41/101 USB: serial: kobil_sct: fix NULL-deref in write
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 21ce57840243c7b70fbc1ebd3dceeb70bb6e9e09 upstream.
Fix NULL-pointer dereference in write() should the device lack the expected interrupt-out endpoint:
Unable to handle kernel NULL pointer dereference at virtual address 00000054
...
PC is at kobil_write+0x144/0x2a0 [kobil_sct]
--- drivers/usb/serial/kobil_sct.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/serial/kobil_sct.c +12 -0
@@ -51,6 +51,7 @@/* Function prototypes */ +static int kobil_attach (struct usb_serial *serial);static int kobil_port_probe (struct usb_serial_port *probe);static int kobil_port_remove (struct usb_serial_port *probe);static int kobil_open (struct tty_struct *tty,struct usb_serial_port *port);
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_de .description = "KOBIL USB smart card terminal", .id_table = id_table, .num_ports = 1, + .attach = kobil_attach, .port_probe = kobil_port_probe, .port_remove = kobil_port_remove, .ioctl = kobil_ioctl,
@@ -113,6 +115,16 @@ struct kobil_private { }; +static int kobil_attach (struct usb_serial *serial) +{ +if (serial->num_interrupt_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing interrupt-out endpoint\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int kobil_port_probe (struct usb_serial_port *port) {struct usb_serial *serial = port->serial;
Greg Kroah-Hartman
maintainerPATCH 42/101 USB: serial: mos7840: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5c75633ef751dd4cd8f443dc35152c1ae563162e upstream.
Fix NULL-pointer dereference in open() should the device lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at mos7840_open+0x88/0x8dc [mos7840]
Note that we continue to treat the interrupt-in endpoint as optional for now.
--- drivers/usb/serial/mos7840.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/serial/mos7840.c +12 -0
@@ -2116,6 +2116,17 @@ static int mos7840_calc_num_ports(structreturn mos7840_num_ports; } +static int mos7840_attach (struct usb_serial *serial) +{ +if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int mos7840_port_probe (struct usb_serial_port *port) {struct usb_serial *serial = port->serial;
@@ -2391,6 +2402,7 @@ static struct usb_serial_driver moschip7 .tiocmset = mos7840_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, + .attach = mos7840_attach, .port_probe = mos7840_port_probe, .port_remove = mos7840_port_remove, .read_bulk_callback = mos7840_bulk_in_callback,
Greg Kroah-Hartman
maintainerPATCH 43/101 USB: serial: mos7720: fix NULL-deref at open
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b05aebc25fdc5aeeac3ee29f0dc9f58dd07c13cc upstream.
Fix NULL-pointer dereference at port open if a device lacks the expected bulk in and out endpoints.
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf071c20>] (mos7720_open [mos7720]) from [<bf0490e0>] (serial_port_activate+0x68/0x98 [usbserial]) [<bf0490e0>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8) [<c0470ca4>] (tty_port_open) from [<bf049d98>] (serial_open+0x48/0x6c [usbserial]) [<bf049d98>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
--- drivers/usb/serial/mos7720.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/mos7720.c +5 -0
@@ -1920,6 +1920,11 @@ static int mos7720_startup(struct usb_seu16 product;int ret_val; +if (serial->num_bulk_in <2 || serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing bulk endpoints\n" ); +return -ENODEV ; + } + product =le16_to_cpu (serial->dev->descriptor.idProduct); dev = serial->dev;
Greg Kroah-Hartman
maintainerPATCH 44/101 USB: serial: mos7720: fix use-after-free on probe errors
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 91a1ff4d53c5184d383d0baeeaeab6f9736f2ff3 upstream.
The interrupt URB was submitted on probe but never stopped on probe errors. This can lead to use-after-free issues in the completion handler when accessing the freed usb-serial struct:
Unable to handle kernel paging request at virtual address 6b6b6be7
...
[<bf052e70>] (mos7715_interrupt_callback [mos7720]) from [<c052a894>] (__usb_hcd_giveback_urb+0x80/0x140) [<c052a894>] (__usb_hcd_giveback_urb) from [<c052a9a4>] (usb_hcd_giveback_urb+0x50/0x138) [<c052a9a4>] (usb_hcd_giveback_urb) from [<c0550684>] (musb_giveback+0xc8/0x1cc)
--- drivers/usb/serial/mos7720.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7720.c +5 -1
@@ -1965,8 +1965,10 @@ static int mos7720_startup(struct usb_se#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT if (product ==MOSCHIP_DEVICE_ID_7715 ) { ret_val =mos7715_parport_init (serial); -if (ret_val <0 ) +if (ret_val <0 ) { +usb_kill_urb (serial->port[0 ]->interrupt_in_urb);return ret_val; + } }#endif /* LSR For Port 1 */
@@ -1978,6 +1980,8 @@ static int mos7720_startup(struct usb_sestatic void mos7720_release (struct usb_serial *serial) { +usb_kill_urb (serial->port[0 ]->interrupt_in_urb); +#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT /* close the parallel port */
Greg Kroah-Hartman
maintainerPATCH 45/101 USB: serial: mos7720: fix parport use-after-free on probe errors
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 75dd211e773afcbc264677b0749d1cf7d937ab2d upstream.
Do not submit the interrupt URB until after the parport has been successfully registered to avoid another use-after-free in the completion handler when accessing the freed parport private data in case of a racing completion.
--- drivers/usb/serial/mos7720.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/usb/serial/mos7720.c +8 -10
@@ -1955,22 +1955,20 @@ static int mos7720_startup(struct usb_seusb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), (__u8 )0x03 ,0x00 ,0x01 ,0x00 ,NULL ,0x00 ,5000 ); -/* start the interrupt urb */ - ret_val =usb_submit_urb (serial->port[0 ]->interrupt_in_urb,GFP_KERNEL ); -if (ret_val) -dev_err (&dev->dev, -"%s - Error %d submitting control urb\n" , - __func__, ret_val); -#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT if (product ==MOSCHIP_DEVICE_ID_7715 ) { ret_val =mos7715_parport_init (serial); -if (ret_val <0 ) { -usb_kill_urb (serial->port[0 ]->interrupt_in_urb); +if (ret_val <0 )return ret_val; - } }#endif +/* start the interrupt urb */ + ret_val =usb_submit_urb (serial->port[0 ]->interrupt_in_urb,GFP_KERNEL ); +if (ret_val) { +dev_err (&dev->dev,"failed to submit interrupt urb: %d\n" , + ret_val); + } +/* LSR For Port 1 */ read_mos_reg (serial,0 ,MOS7720_LSR , &data);dev_dbg (&dev->dev,"LSR:%x\n" , data);
Greg Kroah-Hartman
maintainerPATCH 46/101 USB: serial: mos7720: fix parallel probe
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit fde1faf872ed86d88e245191bc15a8e57368cd1c upstream.
A static usb-serial-driver structure that is used to initialise the interrupt URB was modified during probe depending on the currently probed device type, something which could break a parallel probe of a device of a different type.
Fix this up by overriding the default completion callback for MCS7715 devices in attach() instead. We may want to use two usb-serial driver instances for the two types later.
--- drivers/usb/serial/mos7720.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-)
drivers/usb/serial/mos7720.c +7 -23
@@ -65,8 +65,6 @@ struct moschip_port {struct urb *write_urb_pool[NUM_URBS ]; }; -static struct usb_serial_driver moschip7720_2port_driver; -#define USB_VENDOR_ID_MOSCHIP 0x9710#define MOSCHIP_DEVICE_ID_7720 0x7720#define MOSCHIP_DEVICE_ID_7715 0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callbatty_port_tty_wakeup (&mos7720_port->port->port); } -/* -* mos77xx_probe -* this function installs the appropriate read interrupt endpoint callback -* depending on whether the device is a 7720 or 7715, thus avoiding costly -* run-time checks in the high-frequency callback routine itself. -*/ -static int mos77xx_probe (struct usb_serial *serial, -const struct usb_device_id *id) -{ -if (id->idProduct ==MOSCHIP_DEVICE_ID_7715 ) - moschip7720_2port_driver.read_int_callback = - mos7715_interrupt_callback; -else - moschip7720_2port_driver.read_int_callback = - mos7720_interrupt_callback; - -return 0 ; -} -static int mos77xx_calc_num_ports (struct usb_serial *serial) {u16 product =le16_to_cpu (serial->dev->descriptor.idProduct);
@@ -1949,6 +1928,12 @@ static int mos7720_startup(struct usb_se tmp->interrupt_in_endpointAddress; serial->port[1 ]->interrupt_in_urb =NULL ; serial->port[1 ]->interrupt_in_buffer =NULL ; + +if (serial->port[0 ]->interrupt_in_urb) { +struct urb *urb = serial->port[0 ]->interrupt_in_urb; + + urb->complete = mos7715_interrupt_callback; + } }/* setting configuration feature to one */
@@ -2063,7 +2048,6 @@ static struct usb_serial_driver moschip7 .close = mos7720_close, .throttle = mos7720_throttle, .unthrottle = mos7720_unthrottle, - .probe = mos77xx_probe, .attach = mos7720_startup, .release = mos7720_release, .port_probe = mos7720_port_probe,
@@ -2077,7 +2061,7 @@ static struct usb_serial_driver moschip7 .chars_in_buffer = mos7720_chars_in_buffer, .break_ctl = mos7720_break, .read_bulk_callback = mos7720_bulk_in_callback, - .read_int_callback = NULL /* dynamically assigned in probe() */ + .read_int_callback = mos7720_interrupt_callback, };static struct usb_serial_driver *const serial_drivers[] = {
Greg Kroah-Hartman
maintainerPATCH 47/101 usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit c95a9f83711bf53faeb4ed9bbb63a3f065613dfb upstream.
We normally use the passed in gfp flags for allocations, it's just these two which were missed.
--- drivers/usb/host/xhci-mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-mem.c +2 -2
@@ -2436,7 +2436,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,* "physically contiguous and 64-byte (cache line) aligned". */ xhci->dcbaa =dma_alloc_coherent (dev,sizeof (*xhci->dcbaa), &dma, -GFP_KERNEL ); + flags);if (!xhci->dcbaa) goto fail;memset (xhci->dcbaa,0 ,sizeof *(xhci->dcbaa));
@@ -2532,7 +2532,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, xhci->erst.entries =dma_alloc_coherent (dev,sizeof (struct xhci_erst_entry ) *ERST_NUM_SEGS , &dma, -GFP_KERNEL ); + flags);if (!xhci->erst.entries) goto fail; xhci_dbg_trace(xhci, trace_xhci_dbg_init,
Greg Kroah-Hartman
maintainerPATCH 48/101 xhci: Use delayed_work instead of timer for command timeout
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: OGAWA Hirofumi <[email protected]>
commit cb4d5ce588c5ff68e0fdd30370a0e6bc2c0a736b upstream.
This is preparation to fix abort operation race (See "xhci: Fix race related to abort operation"). To make timeout sleepable, use delayed_work instead of timer.
--- drivers/usb/host/xhci-mem.c | 7 +++---- drivers/usb/host/xhci-ring.c | 26 ++++++++++++++++---------- drivers/usb/host/xhci.h | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-)
drivers/usb/host/xhci-mem.c +3 -4
@@ -1829,7 +1829,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xint size;int i, j, num_ports; -del_timer_sync (&xhci->cmd_timer); +cancel_delayed_work_sync (&xhci->cmd_timer);/* Free the Event Ring Segment Table and the actual Event Ring */ size =sizeof (struct xhci_erst_entry )*(xhci->erst.num_entries);
@@ -2395,9 +2395,8 @@ int xhci_mem_init(struct xhci_hcd *xhci,INIT_LIST_HEAD (&xhci->cmd_list); -/* init command timeout timer */ -setup_timer (&xhci->cmd_timer, xhci_handle_command_timeout, - (unsigned long )xhci); +/* init command timeout work */ +INIT_DELAYED_WORK (&xhci->cmd_timer, xhci_handle_command_timeout); page_size =readl (&xhci->op_regs->page_size); xhci_dbg_trace(xhci, trace_xhci_dbg_init,
drivers/usb/host/xhci-ring.c +16 -10
@@ -280,6 +280,11 @@ void xhci_ring_cmd_db(struct xhci_hcd *xreadl (&xhci->dba->doorbell[0 ]); } +static bool xhci_mod_cmd_timer (struct xhci_hcd *xhci,unsigned long delay) +{ +return mod_delayed_work (system_wq, &xhci->cmd_timer, delay); +} +static int xhci_abort_cmd_ring (struct xhci_hcd *xhci) {u64 temp_64;
@@ -296,7 +301,7 @@ static int xhci_abort_cmd_ring(struct xh* but the completion event in never sent. Use the cmd timeout timer to * handle those cases. Use twice the time to cover the bit polling retry */ -mod_timer (&xhci->cmd_timer, jiffies + (2 *XHCI_CMD_DEFAULT_TIMEOUT )); +xhci_mod_cmd_timer (xhci,2 *XHCI_CMD_DEFAULT_TIMEOUT );xhci_write_64 (xhci, temp_64 |CMD_RING_ABORT , &xhci->op_regs->cmd_ring);
@@ -321,7 +326,7 @@ static int xhci_abort_cmd_ring(struct xhxhci_err (xhci,"Stopped the command ring failed, " "maybe the host is dead\n" ); -del_timer (&xhci->cmd_timer); +cancel_delayed_work (&xhci->cmd_timer); xhci->xhc_state |=XHCI_STATE_DYING ;xhci_quiesce (xhci);xhci_halt (xhci);
@@ -1252,21 +1257,22 @@ static void xhci_handle_stopped_cmd_ringif ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && !(xhci->xhc_state &XHCI_STATE_DYING )) { xhci->current_cmd = cur_cmd; -mod_timer (&xhci->cmd_timer, jiffies +XHCI_CMD_DEFAULT_TIMEOUT ); +xhci_mod_cmd_timer (xhci,XHCI_CMD_DEFAULT_TIMEOUT );xhci_ring_cmd_db (xhci); }return ; } -void xhci_handle_command_timeout (unsigned long data) +void xhci_handle_command_timeout (struct work_struct *work) {struct xhci_hcd *xhci;int ret;unsigned long flags;u64 hw_ring_state;bool second_timeout = false; - xhci = (struct xhci_hcd *) data; + + xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);spin_lock_irqsave (&xhci->lock, flags);
@@ -1274,7 +1280,7 @@ void xhci_handle_command_timeout(unsigne* If timeout work is pending, or current_cmd is NULL, it means we * raced with command completion. Command is handled so just return. */ -if (!xhci->current_cmd ||timer_pending (&xhci->cmd_timer)) { +if (!xhci->current_cmd ||delayed_work_pending (&xhci->cmd_timer)) {spin_unlock_irqrestore (&xhci->lock, flags);return ; }
@@ -1348,7 +1354,7 @@ static void handle_cmd_completion(struct cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); -del_timer (&xhci->cmd_timer); +cancel_delayed_work (&xhci->cmd_timer);trace_xhci_cmd_completion (cmd_trb, (struct xhci_generic_trb *) event);
@@ -1439,7 +1445,7 @@ static void handle_cmd_completion(structif (cmd->cmd_list.next != &xhci->cmd_list) { xhci->current_cmd =list_entry (cmd->cmd_list.next, struct xhci_command, cmd_list); -mod_timer (&xhci->cmd_timer, jiffies +XHCI_CMD_DEFAULT_TIMEOUT ); +xhci_mod_cmd_timer (xhci,XHCI_CMD_DEFAULT_TIMEOUT ); }else if (xhci->current_cmd == cmd) { xhci->current_cmd =NULL ; }
@@ -4074,9 +4080,9 @@ static int queue_command(struct xhci_hcd/* if there are no other commands queued we start the timeout timer */ if (xhci->cmd_list.next == &cmd->cmd_list && - !timer_pending (&xhci->cmd_timer)) { + !delayed_work_pending (&xhci->cmd_timer)) { xhci->current_cmd = cmd; -mod_timer (&xhci->cmd_timer, jiffies +XHCI_CMD_DEFAULT_TIMEOUT ); +xhci_mod_cmd_timer (xhci,XHCI_CMD_DEFAULT_TIMEOUT ); } queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
drivers/usb/host/xhci.h +2 -2
@@ -1552,7 +1552,7 @@ struct xhci_hcd {#define CMD_RING_STATE_STOPPED (1 << 2)struct list_head cmd_list;unsigned int cmd_ring_reserved_trbs; -struct timer_list cmd_timer; +struct delayed_work cmd_timer;struct xhci_command *current_cmd;struct xhci_ring *event_ring;struct xhci_erst erst;
@@ -1915,7 +1915,7 @@ void xhci_queue_config_ep_quirk(struct x unsigned int slot_id, unsigned int ep_index, struct xhci_dequeue_state *deq_state);void xhci_stop_endpoint_command_watchdog (unsigned long arg); -void xhci_handle_command_timeout (unsigned long data); +void xhci_handle_command_timeout (struct work_struct *work);void xhci_ring_ep_doorbell (struct xhci_hcd *xhci,unsigned int slot_id,unsigned int ep_index,unsigned int stream_id);
Greg Kroah-Hartman
maintainerPATCH 49/101 xhci: Fix race related to abort operation
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: OGAWA Hirofumi <[email protected]>
commit 1c111b6c3844a142e03bcfc2fa17bfbdea08e9dc upstream.
Current abort operation has race.
xhci_handle_command_timeout()
xhci_abort_cmd_ring()
xhci_write_64(CMD_RING_ABORT)
xhci_handshake(5s)
do {
check CMD_RING_RUNNING
udelay(1)
...
COMP_CMD_ABORT event
COMP_CMD_STOP event
xhci_handle_stopped_cmd_ring()
restart cmd_ring
CMD_RING_RUNNING become 1 again
} while ()
return -ETIMEDOUT
xhci_write_64(CMD_RING_ABORT)
/* can abort random command */To do abort operation correctly, we have to wait both of COMP_CMD_STOP event and negation of CMD_RING_RUNNING.
But like above, while timeout handler is waiting negation of CMD_RING_RUNNING, event handler can restart cmd_ring. So timeout handler never be notice negation of CMD_RING_RUNNING, and retry of CMD_RING_ABORT can abort random command (BTW, I guess retry of CMD_RING_ABORT was workaround of this race).
To fix this race, this moves xhci_handle_stopped_cmd_ring() to xhci_abort_cmd_ring(). And timeout handler waits COMP_CMD_STOP event.
At this point, timeout handler is owner of cmd_ring, and safely restart cmd_ring by using xhci_handle_stopped_cmd_ring().
[FWIW, as bonus, this way would be easily extend to add CMD_RING_PAUSE operation]
--- drivers/usb/host/xhci-mem.c | 1 drivers/usb/host/xhci-ring.c | 169 ++++++++++++++++++++++--------------------- drivers/usb/host/xhci.h | 1 3 files changed, 91 insertions(+), 80 deletions(-)
drivers/usb/host/xhci-mem.c +1 -0
@@ -2397,6 +2397,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,/* init command timeout work */ INIT_DELAYED_WORK (&xhci->cmd_timer, xhci_handle_command_timeout); +init_completion (&xhci->cmd_ring_stop_completion); page_size =readl (&xhci->op_regs->page_size); xhci_dbg_trace(xhci, trace_xhci_dbg_init,
drivers/usb/host/xhci-ring.c +89 -80
226 lines not on this page · raw message
drivers/usb/host/xhci.h +1 -0
@@ -1553,6 +1553,7 @@ struct xhci_hcd {struct list_head cmd_list;unsigned int cmd_ring_reserved_trbs;struct delayed_work cmd_timer; +struct completion cmd_ring_stop_completion;struct xhci_command *current_cmd;struct xhci_ring *event_ring;struct xhci_erst erst;
Greg Kroah-Hartman
maintainerPATCH 50/101 usb: dwc3: pci: add Intel Gemini Lake PCI ID
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit 8f8983a5683623b62b339d159573f95a1fce44f3 upstream.
Intel Gemini Lake SoC has the same DWC3 than Broxton. Add the new ID to the supported Devices.
--- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +2 -0
@@ -37,6 +37,7 @@#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa#define PCI_DEVICE_ID_INTEL_APL 0x5aaa#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 +#define PCI_DEVICE_ID_INTEL_GLK 0x31aastatic const struct acpi_gpio_params reset_gpios = {0 ,0 , false };static const struct acpi_gpio_params cs_gpios = {1 ,0 , false };
@@ -216,6 +217,7 @@ static const struct pci_device_id dwc3_p { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, { } /* Terminating Entry */ };
Greg Kroah-Hartman
maintainerPATCH 51/101 usb: musb: Fix trying to free already-free IRQ 4
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
commit 8c300fe282fa254ea730c92cb0983e2642dc1fff upstream.
When unloading omap2430, we can get the following splat:
WARNING: CPU: 1 PID: 295 at kernel/irq/manage.c:1478 __free_irq+0xa8/0x2c8
Trying to free already-free IRQ 4
...
[<c01a8b78>] (free_irq) from [<bf0aea84>] (musbhs_dma_controller_destroy+0x28/0xb0 [musb_hdrc]) [<bf0aea84>] (musbhs_dma_controller_destroy [musb_hdrc]) from [<bf09f88c>] (musb_remove+0xf0/0x12c [musb_hdrc]) [<bf09f88c>] (musb_remove [musb_hdrc]) from [<c056a384>] (platform_drv_remove+0x24/0x3c)
...
This is because the irq number in use is 260 nowadays, and the dma controller is using u8 instead of int.
--- drivers/usb/musb/musbhsdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/musbhsdma.h +1 -1
@@ -157,5 +157,5 @@ struct musb_dma_controller {void __iomem *base;u8 channel_count;u8 used_channels; -u8 irq; +int irq; };
Greg Kroah-Hartman
maintainerPATCH 54/101 ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 4763601a56f155ddf94ef35fc2c41504a2de15f5 upstream.
The function returns -EINVAL even if it builds the stream properly. The bogus error code sneaked in during the code refactoring, but it wasn't noticed until now since the returned error code itself is ignored in anyway. Kill it here, but there is no behavior change by this patch, obviously.
--- sound/usb/card.c | 1 - 1 file changed, 1 deletion(-)
sound/usb/card.c +0 -1
@@ -202,7 +202,6 @@ static int snd_usb_create_stream(structif (!snd_usb_parse_audio_interface (chip, interface)) {usb_set_interface (dev, interface,0 );/* reset the current interface */ usb_driver_claim_interface (&usb_audio_driver, iface, (void *)-1L ); -return -EINVAL ; }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 55/101 USB: serial: kl5kusb105: abort on open exception path
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pan Bian <[email protected]>
commit 3c3dd1e058cb01e835dcade4b54a6f13ffaeaf7c upstream.
Function klsi_105_open() calls usb_control_msg() (to "enable read") and checks its return value. When the return value is unexpected, it only assigns the error code to the return variable retval, but does not terminate the exception path. This patch fixes the bug by inserting "goto err_generic_close;" when the call to usb_control_msg() fails.
--- drivers/usb/serial/kl5kusb105.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/kl5kusb105.c +2 -0
@@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_strif (rc <0 ) {dev_err (&port->dev,"Enabling read failed (error = %d)\n" , rc); retval = rc; + goto err_generic_close; }else dev_dbg (&port->dev,"%s - enabled reading\n" , __func__);
@@ -337,6 +338,7 @@ err_disable_read:0 ,/* index */ NULL ,0 , KLSI_TIMEOUT); +err_generic_close:usb_serial_generic_close (port); err_free_cfg:kfree (cfg);
Greg Kroah-Hartman
maintainerPATCH 56/101 ARM: dts: r8a7794: Correct hsusb parent clock
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit dc8ee9dbdba509fb58e23ba79f2e6059fe5d8b3b upstream.
The parent clock of the HSUSB clock is the HP clock, not the MP clock.
--- arch/arm/boot/dts/r8a7794.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/r8a7794.dtsi +1 -1
@@ -1023,7 +1023,7 @@ mstp7_clks: mstp7_clks@e615014c { compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>; - clocks = <&mp_clk>, <&mp_clk>, + clocks = <&mp_clk>, <&hp_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>; #clock-cells = <1>;
Greg Kroah-Hartman
maintainerPATCH 57/101 USB: phy: am335x-control: fix device and of_node leaks
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 015105b12183556771e111e93f5266851e7c5582 upstream.
Make sure to drop the references taken by of_parse_phandle() and bus_find_device() before returning from am335x_get_phy_control().
Note that there is no guarantee that the devres-managed struct phy_control will be valid for the lifetime of the sibling phy device regardless of this change.
--- drivers/usb/phy/phy-am335x-control.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/phy/phy-am335x-control.c +2 -0
@@ -126,10 +126,12 @@ struct phy_control *am335x_get_phy_contrreturn NULL ; dev =bus_find_device (&platform_bus_type,NULL , node, match); +of_node_put (node);if (!dev)return NULL ; ctrl_usb =dev_get_drvdata (dev); +put_device (dev);if (!ctrl_usb)return NULL ;return &ctrl_usb->phy_ctrl;
Greg Kroah-Hartman
maintainerPATCH 58/101 USB: serial: io_ti: bind to interface after fw download
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit e35d6d7c4e6532a89732cf4bace0e910ee684c88 upstream.
Bind to the interface, but do not register any ports, after having downloaded the firmware. The device will still disconnect and re-enumerate, but this way we avoid an error messages from being logged as part of the process:
io_ti: probe of 1-1.3:1.0 failed with error -5
--- drivers/usb/serial/io_ti.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/io_ti.c +1 -2
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_dev_dbg (dev,"%s - Download successful -- Device rebooting...\n" , __func__); -/* return an error on purpose */ -return -ENODEV ; +return 1 ; } stayinbootmode:
Greg Kroah-Hartman
maintainerPATCH 59/101 mei: bus: fix mei_cldev_enable KDoc
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 5026c9cb0744a9cd40242743ca91a5d712f468c6 upstream.
Adjust function name in KDoc.
--- drivers/misc/mei/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/bus.c +1 -1
@@ -399,7 +399,7 @@ bool mei_cldev_enabled(struct mei_cl_devEXPORT_SYMBOL_GPL (mei_cldev_enabled);/** -* mei_cldev_enable_device - enable me client device +* mei_cldev_enable - enable me client device * create connection with me client * * @cldev: me client device
Greg Kroah-Hartman
maintainerPATCH 60/101 staging: iio: ad7606: fix improper setting of oversampling pins
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eva Rachel Retuya <[email protected]>
commit b321a38d2407c7e425c54bc09be909a34e49f740 upstream.
The oversampling ratio is controlled using the oversampling pins, OS [2:0] with OS2 being the MSB control bit, and OS0 the LSB control bit.
The gpio connected to the OS2 pin is not being set correctly, only OS0 and OS1 pins are being set. Fix the typo to allow proper control of the oversampling pins.
--- drivers/staging/iio/adc/ad7606_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7606_core.c +1 -1
@@ -189,7 +189,7 @@ static ssize_t ad7606_store_oversamplingmutex_lock (&indio_dev->mlock);gpio_set_value (st->pdata->gpio_os0, (ret >>0 ) &1 );gpio_set_value (st->pdata->gpio_os1, (ret >>1 ) &1 ); -gpio_set_value (st->pdata->gpio_os1, (ret >>2 ) &1 ); +gpio_set_value (st->pdata->gpio_os2, (ret >>2 ) &1 ); st->oversampling = lval;mutex_unlock (&indio_dev->mlock);
Greg Kroah-Hartman
maintainerPATCH 61/101 usb: dwc3: gadget: always unmap EP0 requests
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit d62145929992f331fdde924d5963ab49588ccc7d upstream.
commit 0416e494ce7d ("usb: dwc3: ep0: correct cache sync issue in case of ep0_bounced") introduced a bug where we would leak DMA resources which would cause us to starve the system of them resulting in failing DMA transfers.
Fix the bug by making sure that we always unmap EP0 requests since those are *always* mapped.
sync issue in case of ep0_bounced")
--- drivers/usb/dwc3/gadget.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/dwc3/gadget.c +4 -4
@@ -259,11 +259,11 @@ void dwc3_gadget_giveback(struct dwc3_epif (req->request.status == -EINPROGRESS ) req->request.status = status; -if (dwc->ep0_bounced && dep->number ==0 ) +if (dwc->ep0_bounced && dep->number <=1 ) dwc->ep0_bounced = false; -else -usb_gadget_unmap_request (&dwc->gadget, &req->request, - req->direction); + +usb_gadget_unmap_request (&dwc->gadget, &req->request, + req->direction); dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", req, dep->name, req->request.actual,
Greg Kroah-Hartman
maintainerPATCH 62/101 usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 7931ec86c1b738e4e90e58c6d95e5f720d45ee56 upstream.
For now this is just a cleanup patch, no functional changes. We will be using the new function to fix a bug introduced long ago by commit 0416e494ce7d ("usb: dwc3: ep0: correct cache sync issue in case of ep0_bounced") and further worsened by commit c0bd5456a470 ("usb: dwc3: ep0: handle non maxpacket aligned transfers > 512")
--- drivers/usb/dwc3/ep0.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/usb/dwc3/ep0.c +18 -12
@@ -55,20 +55,13 @@ static const char *dwc3_ep0_state_string } } -static int dwc3_ep0_start_trans (struct dwc3 *dwc,u8 epnum,dma_addr_t buf_dma, -u32 len,u32 type,bool chain) +static void dwc3_ep0_prepare_one_trb (struct dwc3 *dwc,u8 epnum, +dma_addr_t buf_dma,u32 len,u32 type,bool chain) { -struct dwc3_gadget_ep_cmd_params params;struct dwc3_trb *trb;struct dwc3_ep *dep; -int ret; - dep = dwc->eps[epnum]; -if (dep->flags &DWC3_EP_BUSY ) { -dwc3_trace (trace_dwc3_ep0,"%s still busy" , dep->name); -return 0 ; - } trb = &dwc->ep0_trb[dep->free_slot];
@@ -89,15 +82,28 @@ static int dwc3_ep0_start_trans(struct d trb->ctrl |= (DWC3_TRB_CTRL_IOC |DWC3_TRB_CTRL_LST ); -if (chain) +trace_dwc3_prepare_trb (dep, trb); +} + +static int dwc3_ep0_start_trans (struct dwc3 *dwc,u8 epnum,dma_addr_t buf_dma, +u32 len,u32 type,bool chain) +{ +struct dwc3_gadget_ep_cmd_params params; +struct dwc3_ep *dep; +int ret; + + dep = dwc->eps[epnum]; +if (dep->flags &DWC3_EP_BUSY ) { +dwc3_trace (trace_dwc3_ep0,"%s still busy" , dep->name);return 0 ; + } + +dwc3_ep0_prepare_one_trb (dwc, epnum, buf_dma, len, type, chain);memset (¶ms,0 ,sizeof (params)); params.param0 =upper_32_bits (dwc->ep0_trb_addr); params.param1 =lower_32_bits (dwc->ep0_trb_addr); -trace_dwc3_prepare_trb (dep, trb); - ret =dwc3_send_gadget_ep_cmd (dwc, dep->number,DWC3_DEPCMD_STARTTRANSFER , ¶ms);if (ret <0 ) {
Greg Kroah-Hartman
maintainerPATCH 63/101 usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 19ec31230eb3084431bc2e565fd085f79f564274 upstream.
Let's call dwc3_ep0_prepare_one_trb() explicitly because there are occasions where we will need more than one TRB to handle an EP0 transfer.
A follow-up patch will fix one bug related to
multiple-TRB Data Phases when it comes to
mapping/unmapping requests for DMA.
--- drivers/usb/dwc3/ep0.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/usb/dwc3/ep0.c +15 -13
@@ -85,8 +85,7 @@ static void dwc3_ep0_prepare_one_trb(strtrace_dwc3_prepare_trb (dep, trb); } -static int dwc3_ep0_start_trans (struct dwc3 *dwc,u8 epnum,dma_addr_t buf_dma, -u32 len,u32 type,bool chain) +static int dwc3_ep0_start_trans (struct dwc3 *dwc,u8 epnum) {struct dwc3_gadget_ep_cmd_params params;struct dwc3_ep *dep;
@@ -98,8 +97,6 @@ static int dwc3_ep0_start_trans(struct dreturn 0 ; } -dwc3_ep0_prepare_one_trb (dwc, epnum, buf_dma, len, type, chain); -memset (¶ms,0 ,sizeof (params)); params.param0 =upper_32_bits (dwc->ep0_trb_addr); params.param1 =lower_32_bits (dwc->ep0_trb_addr);
@@ -317,8 +314,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc {int ret; - ret =dwc3_ep0_start_trans (dwc,0 , dwc->ctrl_req_addr,8 , +dwc3_ep0_prepare_one_trb (dwc,0 , dwc->ctrl_req_addr,8 ,DWC3_TRBCTL_CONTROL_SETUP , false); + ret =dwc3_ep0_start_trans (dwc,0 );WARN_ON (ret <0 ); }
@@ -877,9 +875,9 @@ static void dwc3_ep0_complete_data(struc dwc->ep0_next_event =DWC3_EP0_COMPLETE ; - ret =dwc3_ep0_start_trans (dwc, epnum, - dwc->ctrl_req_addr,0 , -DWC3_TRBCTL_CONTROL_DATA , false); +dwc3_ep0_prepare_one_trb (dwc, epnum, dwc->ctrl_req_addr, +0 ,DWC3_TRBCTL_CONTROL_DATA , false); + ret =dwc3_ep0_start_trans (dwc, epnum);WARN_ON (ret <0 ); } }
@@ -961,9 +959,10 @@ static void __dwc3_ep0_do_control_data(s req->direction = !!dep->number;if (req->request.length ==0 ) { - ret =dwc3_ep0_start_trans (dwc, dep->number, +dwc3_ep0_prepare_one_trb (dwc, dep->number, dwc->ctrl_req_addr,0 ,DWC3_TRBCTL_CONTROL_DATA , false); + ret =dwc3_ep0_start_trans (dwc, dep->number); }else if (!IS_ALIGNED (req->request.length, dep->endpoint.maxpacket) && (dep->number ==0 )) {u32 transfer_size =0 ;
@@ -981,7 +980,7 @@ static void __dwc3_ep0_do_control_data(sif (req->request.length >DWC3_EP0_BOUNCE_SIZE ) { transfer_size =ALIGN (req->request.length - maxpacket, maxpacket); - ret = dwc3_ep0_start_trans(dwc, dep->number, + dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma, transfer_size, DWC3_TRBCTL_CONTROL_DATA,
@@ -993,9 +992,10 @@ static void __dwc3_ep0_do_control_data(s dwc->ep0_bounced = true; - ret =dwc3_ep0_start_trans (dwc, dep->number, +dwc3_ep0_prepare_one_trb (dwc, dep->number, dwc->ep0_bounce_addr, transfer_size,DWC3_TRBCTL_CONTROL_DATA , false); + ret =dwc3_ep0_start_trans (dwc, dep->number); }else { ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);
@@ -1004,9 +1004,10 @@ static void __dwc3_ep0_do_control_data(sreturn ; } - ret =dwc3_ep0_start_trans (dwc, dep->number, req->request.dma, +dwc3_ep0_prepare_one_trb (dwc, dep->number, req->request.dma, req->request.length,DWC3_TRBCTL_CONTROL_DATA , false); + ret =dwc3_ep0_start_trans (dwc, dep->number); }WARN_ON (ret <0 );
@@ -1020,8 +1021,9 @@ static int dwc3_ep0_start_control_status type = dwc->three_stage_setup ?DWC3_TRBCTL_CONTROL_STATUS3 :DWC3_TRBCTL_CONTROL_STATUS2 ; -return dwc3_ep0_start_trans (dwc, dep->number, +dwc3_ep0_prepare_one_trb (dwc, dep->number, dwc->ctrl_req_addr,0 , type, false); +return dwc3_ep0_start_trans (dwc, dep->number); }static void __dwc3_ep0_do_control_status (struct dwc3 *dwc,struct dwc3_ep *dep)
Greg Kroah-Hartman
maintainerPATCH 64/101 stable-fixup: hotplug: fix unused function warning
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[resolves a messed up backport, so no matching upstream commit]
The backport of upstream commit 777c6e0daebb ("hotplug: Make register and unregister notifier API symmetric") to linux-4.4.y introduced a harmless warning in 'allnoconfig' builds as spotted by kernelci.org:
kernel/cpu.c:226:13: warning: 'cpu_notify_nofail' defined but not used [-Wunused-function]
So far, this is the only stable tree that is affected, as linux-4.6 and higher contain commit 984581728eb4 ("cpu/hotplug: Split out cpu down functions") that makes the function used in all configurations, while older longterm releases so far don't seem to have a backport of 777c6e0daebb.
The fix for the warning is trivial: move the unused function back into the #ifdef section where it was before.
--- kernel/cpu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/cpu.c +5 -4
@@ -223,10 +223,6 @@ static int cpu_notify(unsigned long val,return __cpu_notify (val, v,-1 ,NULL ); } -static void cpu_notify_nofail (unsigned long val,void *v) -{ -BUG_ON (cpu_notify (val, v)); -}EXPORT_SYMBOL (register_cpu_notifier);EXPORT_SYMBOL (__register_cpu_notifier);
@@ -245,6 +241,11 @@ void __unregister_cpu_notifier(struct noEXPORT_SYMBOL (__unregister_cpu_notifier);#ifdef CONFIG_HOTPLUG_CPU +static void cpu_notify_nofail (unsigned long val,void *v) +{ +BUG_ON (cpu_notify (val, v)); +} +/** * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU * @cpu: a CPU id
Greg Kroah-Hartman
maintainerPATCH 65/101 ath10k: use the right length of "background"
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Iooss <[email protected]>
commit 31b239824ece321c09bdb8e61e1d14814eaba38b upstream.
The word "background" contains 10 characters so the third argument of strncmp() need to be 10 in order to match this prefix correctly.
--- drivers/net/wireless/ath/ath10k/spectral.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/spectral.c +1 -1
@@ -338,7 +338,7 @@ static ssize_t write_file_spec_scan_ctl( }else { res = -EINVAL ; } - }else if (strncmp ("background" , buf,9 ) ==0 ) { + }else if (strncmp ("background" , buf,10 ) ==0 ) { res =ath10k_spectral_scan_config (ar,SPECTRAL_BACKGROUND ); }else if (strncmp ("manual" , buf,6 ) ==0 ) { res =ath10k_spectral_scan_config (ar,SPECTRAL_MANUAL );
Greg Kroah-Hartman
maintainerPATCH 66/101 cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 328cf6927bb72cadefddebbc9a23c793108147a2 upstream.
If CONFIG_ETRAX_AXISFLASHMAP is not configured, the flash rescue image object file is empty. With recent versions of binutils, this results in the following build error.
cris-linux-objcopy: error:
the input file 'arch/cris/boot/rescue/rescue.o' has no sections
This is seen, for example, when trying to build cris:allnoconfig with recently generated toolchains.
Since it does not make sense to build a flash rescue image if there is no flash, only build it if CONFIG_ETRAX_AXISFLASHMAP is enabled.
--- arch/cris/boot/rescue/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/cris/boot/rescue/Makefile +8 -0
@@ -10,6 +10,9 @@ asflags-y += $(LINUXINCLUDE) ccflags-y += -O2 $(LINUXINCLUDE) + +ifdef CONFIG_ETRAX_AXISFLASHMAP + arch-$(CONFIG_ETRAX_ARCH_V10) = v10 arch-$(CONFIG_ETRAX_ARCH_V32) = v32
@@ -28,6 +31,11 @@ $(obj)/rescue.bin: $(obj)/rescue.o FORCE $(call if_changed,objcopy) cp -p $(obj)/rescue.bin $(objtree) +else +$(obj)/rescue.bin: + +endif + $(obj)/testrescue.bin: $(obj)/testrescue.o $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin # Pad it to 784 bytes
Greg Kroah-Hartman
maintainerPATCH 67/101 hwmon: (scpi) Fix module autoload
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Martinez Canillas <[email protected]>
commit 13edb767aa609b6efb7c0c2b57fbd72a6ded0eed upstream.
If the driver is built as a module, autoload won't work because the module alias information is not filled. So user-space can't match the registered device with the corresponding module.
Export the module alias information using the MODULE_DEVICE_TABLE() macro.
Before this patch:
$ modinfo drivers/hwmon/scpi-hwmon.ko | grep alias $
After this patch:
$ modinfo drivers/hwmon/scpi-hwmon.ko | grep alias alias: of:N*T*Carm,scpi-sensorsC* alias: of:N*T*Carm,scpi-sensors
--- drivers/hwmon/scpi-hwmon.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/scpi-hwmon.c +1 -0
@@ -272,6 +272,7 @@ static const struct of_device_id scpi_of {.compatible = "arm,scpi-sensors"}, {}, }; +MODULE_DEVICE_TABLE (of, scpi_of_match);static struct platform_driver scpi_hwmon_platdrv = { .driver = {
Greg Kroah-Hartman
maintainerPATCH 68/101 hwmon: (amc6821) sign extension temperature
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared Bents <[email protected]>
commit 4538bfbf2d9f1fc48c07ac0cc0ee58716fe7fe96 upstream.
Converts the unsigned temperature values from the i2c read to be sign extended as defined in the datasheet so that negative temperatures are properly read.
--- drivers/hwmon/amc6821.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/amc6821.c +2 -2
@@ -188,8 +188,8 @@ static struct amc6821_data *amc6821_upda !data->valid) {for (i =0 ; i <TEMP_IDX_LEN ; i++) - data->temp[i] =i2c_smbus_read_byte_data (client, - temp_reg[i]); + data->temp[i] = (int8_t )i2c_smbus_read_byte_data ( + client, temp_reg[i]); data->stat1 =i2c_smbus_read_byte_data (client,AMC6821_REG_STAT1 );
Greg Kroah-Hartman
maintainerPATCH 69/101 hwmon: (ds620) Fix overflows seen when writing temperature limits
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit e36ce99ee0815d7919a7b589bfb66f3de50b6bc7 upstream.
Module test reports:
temp1_max: Suspected overflow: [160000 vs. 0]temp1_min: Suspected overflow: [160000 vs. 0]
This is seen because the values passed when writing temperature limits are unbound.
--- drivers/hwmon/ds620.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ds620.c +1 -1
@@ -166,7 +166,7 @@ static ssize_t set_temp(struct device *dif (res)return res; - val = (val *10 /625 ) *8 ; + val = (clamp_val (val,-128000 ,128000 ) *10 /625 ) *8 ;mutex_lock (&data->update_lock); data->temp[attr->index] = val;
Greg Kroah-Hartman
maintainerPATCH 70/101 hwmon: (nct7802) Fix overflows seen when writing into limit attributes
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit c0d04e9112ad59d73f23f3b0f6726c5e798dfcbf upstream.
Fix overflows seen when writing voltage and temperature limit attributes.
The value passed to DIV_ROUND_CLOSEST() needs to be clamped, and the value parameter passed to nct7802_write_fan_min() is an unsigned long.
Also, writing values larger than 2700000 into a fan limit attribute results in writing 0 into the chip's limit registers. The exact behavior when writing this value is unspecified. For consistency, report a limit of 1350000 if the chip register reads 0. This may be wrong, and the chip behavior should be verified with the actual chip, but it is better than reporting a value of 0 (which, when written, results in writing a value of 0x1fff into the chip register).
--- drivers/hwmon/nct7802.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hwmon/nct7802.c +5 -3
@@ -259,13 +259,15 @@ static int nct7802_read_fan_min(struct n ret =0 ; else if (ret) ret =DIV_ROUND_CLOSEST (1350000U , ret); + else + ret =1350000U ; abort:mutex_unlock (&data->access_lock);return ret; }static int nct7802_write_fan_min (struct nct7802_data *data,u8 reg_fan_low, -u8 reg_fan_high,unsigned int limit) +u8 reg_fan_high,unsigned long limit) {int err;
@@ -326,8 +328,8 @@ static int nct7802_write_voltage(structint shift =8 -REG_VOLTAGE_LIMIT_MSB_SHIFT [index -1 ][nr];int err; + voltage =clamp_val (voltage,0 ,0x3ff * nct7802_vmul[nr]); voltage =DIV_ROUND_CLOSEST (voltage, nct7802_vmul[nr]); - voltage =clamp_val (voltage,0 ,0x3ff );mutex_lock (&data->access_lock); err = regmap_write(data->regmap,
@@ -402,7 +404,7 @@ static ssize_t store_temp(struct deviceif (err <0 )return err; - val =clamp_val (DIV_ROUND_CLOSEST (val,1000 ),-128 ,127 ); + val =DIV_ROUND_CLOSEST (clamp_val (val,-128000 ,127000 ),1000 ); err =regmap_write (data->regmap, nr, val &0xff );return err ? : count;
Greg Kroah-Hartman
maintainerPATCH 71/101 hwmon: (g762) Fix overflows and crash seen when writing limit attributes
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 4fccd4a1e8944033bcd7693ea4e8fb478cd2059a upstream.
Fix overflows seen when writing into fan speed limit attributes. Also fix crash due to division by zero, seen when certain very large values (such as 2147483648, or 0x80000000) are written into fan speed limit attributes.
--- drivers/hwmon/g762.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/hwmon/g762.c +7 -4
@@ -193,14 +193,17 @@ static inline unsigned int rpm_from_cnt(* Convert fan RPM value from sysfs into count value for fan controller * register (FAN_SET_CNT). */ -static inline unsigned char cnt_from_rpm (u32 rpm,u32 clk_freq,u16 p, +static inline unsigned char cnt_from_rpm (unsigned long rpm,u32 clk_freq,u16 p,u8 clk_div,u8 gear_mult) { -if (!rpm)/* to stop the fan, set cnt to 255 */ +unsigned long f1 = clk_freq *30 * gear_mult; +unsigned long f2 = p * clk_div; + +if (!rpm)/* to stop the fan, set cnt to 255 */ return 0xff ; -return clamp_val (((clk_freq *30 * gear_mult) / (rpm * p * clk_div)), -0 ,255 ); + rpm =clamp_val (rpm, f1 / (255 * f2),ULONG_MAX / f2); +return DIV_ROUND_CLOSEST (f1, rpm * f2); }/* helper to grab and cache data, at most one time per second */
Greg Kroah-Hartman
maintainerPATCH 72/101 clk: clk-wm831x: fix a logic error
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pan Bian <[email protected]>
commit 20979202ee6e4c68dab7bcf408787225a656d18e upstream.
Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188561. Function wm831x_clkout_is_prepared() returns "true" when it fails to read CLOCK_CONTROL_1. "true" means the device is already prepared. So return "true" on the read failure seems improper.
--- drivers/clk/clk-wm831x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-wm831x.c +1 -1
@@ -247,7 +247,7 @@ static int wm831x_clkout_is_prepared(strif (ret <0 ) {dev_err (wm831x->dev,"Unable to read CLOCK_CONTROL_1: %d\n" , ret); -return true; +return false; }return (ret &WM831X_CLKOUT_ENA ) !=0 ;
Greg Kroah-Hartman
maintainerPATCH 74/101 iommu/amd: Missing error code in amd_iommu_init_device()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 24c790fbf5d8f54c8c82979db11edea8855b74bf upstream.
We should set "ret" to -EINVAL if iommu_group_get() fails.
--- drivers/iommu/amd_iommu_v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/amd_iommu_v2.c +3 -1
@@ -809,8 +809,10 @@ int amd_iommu_init_device(struct pci_dev goto out_free_domain; group =iommu_group_get (&pdev->dev); -if (!group) +if (!group) { + ret = -EINVAL ; goto out_free_domain; + } ret =iommu_attach_group (dev_state->domain, group);if (ret !=0 )
Greg Kroah-Hartman
maintainerPATCH 75/101 iommu/amd: Fix the left value check of cmd buffer
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huang Rui <[email protected]>
commit 432abf68a79332282329286d190e21fe3ac02a31 upstream.
The generic command buffer entry is 128 bits (16 bytes), so the offset of tail and head pointer should be 16 bytes aligned and increased with 0x10 per command.
When cmd buf is full, head = (tail + 0x10) % CMD_BUFFER_SIZE.
So when left space of cmd buf should be able to store only two command, we should be issued one COMPLETE_WAIT additionally to wait all older commands completed. Then the left space should be increased after IOMMU fetching from cmd buf.
So left check value should be left <= 0x20 (two commands).
--- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd_iommu.c +1 -1
@@ -926,7 +926,7 @@ again: next_tail = (tail +sizeof (*cmd)) %CMD_BUFFER_SIZE ; left = (head - next_tail) %CMD_BUFFER_SIZE ; -if (left <=2 ) { +if (left <=0x20 ) {struct iommu_cmd sync_cmd;volatile u64 sem =0 ;int ret;
Greg Kroah-Hartman
maintainerPATCH 76/101 iommu/vt-d: Fix pasid table size encoding
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Pan <[email protected]>
commit 65ca7f5f7d1cdde6c25172fe6107cd16902f826f upstream.
Different encodings are used to represent supported PASID bits and number of PASID table entries.
The current code assigns ecap_pss directly to extended context table entry PTS which is wrong and could result in writing non-zero bits to the reserved fields. IOMMU fault reason 11 will be reported when reserved bits are nonzero. This patch converts ecap_pss to extend context entry pts encoding based on VT-d spec. Chapter 9.4 as follows:
- number of PASID bits = ecap_pss + 1
- number of PASID table entries = 2^(pts + 5)
Software assigned limit of pasid_max value is also respected to match the allocation limitation of PASID table.
--- drivers/iommu/intel-iommu.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +22 -1
@@ -5020,6 +5020,25 @@ static void intel_iommu_remove_device(st }#ifdef CONFIG_INTEL_IOMMU_SVM +#define MAX_NR_PASID_BITS (20) +static inline unsigned long intel_iommu_get_pts (struct intel_iommu *iommu) +{ +/* +* Convert ecap_pss to extend context entry pts encoding, also +* respect the soft pasid_max value set by the iommu. +* - number of PASID bits = ecap_pss + 1 +* - number of PASID table entries = 2^(pts + 5) +* Therefore, pts = ecap_pss - 4 +* e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15 +*/ +if (ecap_pss (iommu->ecap) <5 ) +return 0 ; + +/* pasid_max is encoded as actual number of entries not the bits */ +return find_first_bit ((unsigned long *)&iommu->pasid_max, +MAX_NR_PASID_BITS ) -5 ; +} +int intel_iommu_enable_pasid (struct intel_iommu *iommu,struct intel_svm_dev *sdev) {struct device_domain_info *info;
@@ -5052,7 +5071,9 @@ int intel_iommu_enable_pasid(struct inteif (!(ctx_lo &CONTEXT_PASIDE )) { context[1 ].hi = (u64 )virt_to_phys (iommu->pasid_state_table); - context[1 ].lo = (u64 )virt_to_phys (iommu->pasid_table) |ecap_pss (iommu->ecap); + context[1 ].lo = (u64 )virt_to_phys (iommu->pasid_table) | +intel_iommu_get_pts (iommu); +wmb ();/* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both * extended to permit requests-with-PASID if the PASIDE bit
Greg Kroah-Hartman
maintainerPATCH 77/101 iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xunlei Pang <[email protected]>
commit aec0e86172a79eb5e44aff1055bb953fe4d47c59 upstream.
We met the DMAR fault both on hpsa P420i and P421 SmartArray controllers
under kdump, it can be steadily reproduced on several different machines,
the dmesg log is like:
HP HPSA Driver (v 3.4.16-0)
hpsa 0000:02:00.0: using doorbell to reset controller
hpsa 0000:02:00.0: board ready after hard reset.
hpsa 0000:02:00.0: Waiting for controller to respond to no-op
DMAR: Setting identity map for device 0000:02:00.0 [0xe8000 - 0xe8fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xf4000 - 0xf4fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6e000 - 0xbdf6efff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6f000 - 0xbdf7efff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf7f000 - 0xbdf82fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf83000 - 0xbdf84fff]
DMAR: DRHD: handling fault status reg 2
DMAR: [DMA Read] Request device [02:00.0] fault addr fffff000 [fault reason 06] PTE Read access is not set hpsa 0000:02:00.0: controller message 03:00 timed out
hpsa 0000:02:00.0: no-op failed; re-trying
After some debugging, we found that the fault addr is from DMA initiated at the driver probe stage after reset(not in-flight DMA), and the corresponding pte entry value is correct, the fault is likely due to the old iommu caches of the in-flight DMA before it.
Thus we need to flush the old cache after context mapping is setup for the device, where the device is supposed to finish reset at its driver probe stage and no in-flight DMA exists hereafter.
I'm not sure if the hardware is responsible for invalidating all the related caches allocated in the iommu hardware before, but seems not the case for hpsa, actually many device drivers have problems in properly resetting the hardware. Anyway flushing (again) by software in kdump kernel when the device gets context mapped which is a quite infrequent operation does little harm.
With this patch, the problematic machine can survive the kdump tests.
--- drivers/iommu/intel-iommu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/iommu/intel-iommu.c +19 -0
@@ -1993,6 +1993,25 @@ static int domain_context_mapping_one(stif (context_present (context)) goto out_unlock; +/* +* For kdump cases, old valid entries may be cached due to the +* in-flight DMA and copied pgtable, but there is no unmapping +* behaviour for them, thus we need an explicit cache flush for +* the newly-mapped device. For kdump, at this point, the device +* is supposed to finish reset at its driver probe stage, so no +* in-flight DMA will exist, and we don't need to worry anymore +* hereafter. +*/ +if (context_copied (context)) { +u16 did_old =context_domain_id (context); + +if (did_old >=0 && did_old <cap_ndoms (iommu->cap)) + iommu->flush.flush_context (iommu, did_old, + (((u16 )bus) <<8 ) | devfn, +DMA_CCMD_MASK_NOBIT , +DMA_CCMD_DEVICE_INVL ); + } + pgd = domain->pgd;context_clear_entry (context);
Greg Kroah-Hartman
maintainerPATCH 78/101 ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
commit 5faf071d08ddd1c1be66deaa93a09ccf43f5b538 upstream.
Unfortunately, I seem to have missed a case where an IRQ safe spinlock was required, in samsung_i2s_dai_remove, when I fixed up the other calls in this patch:
316fa9e09ad7 ("ASoC: samsung: Use IRQ safe spin lock calls")
This causes a lockdep warning when unbinding and rebinding the audio card:
[ 104.357664] CPU0 CPU1 [ 104.362174] ---- ---- [ 104.366692] lock(&(&pri_dai->spinlock)->rlock); [ 104.371372] local_irq_disable(); [ 104.377283] lock(&(&substream->self_group.lock)->rlock); [ 104.385259] lock(&(&pri_dai->spinlock)->rlock); [ 104.392469] <Interrupt> [ 104.395072] lock(&(&substream->self_group.lock)->rlock); [ 104.400710] [ 104.400710] *** DEADLOCK ***
--- sound/soc/samsung/i2s.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/samsung/i2s.c +3 -2
@@ -1027,12 +1027,13 @@ static int samsung_i2s_dai_probe(structstatic int samsung_i2s_dai_remove (struct snd_soc_dai *dai) {struct i2s_dai *i2s =snd_soc_dai_get_drvdata (dai); +unsigned long flags;if (!is_secondary (i2s)) {if (i2s->quirks &QUIRK_NEED_RSTCLR ) { -spin_lock (i2s->lock); +spin_lock_irqsave (i2s->lock, flags);writel (0 , i2s->addr +I2SCON ); -spin_unlock (i2s->lock); +spin_unlock_irqrestore (i2s->lock, flags); } }
Greg Kroah-Hartman
maintainerPATCH 79/101 scsi: mvsas: fix command_active typo
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit af15769ffab13d777e55fdef09d0762bf0c249c4 upstream.
gcc-7 notices that the condition in mvs_94xx_command_active looks suspicious:
drivers/scsi/mvsas/mv_94xx.c: In function 'mvs_94xx_command_active':drivers/scsi/mvsas/mv_94xx.c:671:15: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
This was introduced when the mv_printk() statement got added, and leads to the condition being ignored. This is probably harmless.
Changing '&&' to '&' makes the code look reasonable, as we check the command bit before setting and printing it.
--- drivers/scsi/mvsas/mv_94xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mvsas/mv_94xx.c +1 -1
@@ -621,7 +621,7 @@ static void mvs_94xx_command_active(stru {u32 tmp; tmp =mvs_cr32 (mvi,MVS_COMMAND_ACTIVE +(slot_idx >>3 )); -if (tmp &&1 << (slot_idx %32 )) { +if (tmp &1 << (slot_idx %32 )) {mv_printk ("command active %08X, slot [%x].\n" , tmp, slot_idx);mvs_cw32 (mvi,MVS_COMMAND_ACTIVE + (slot_idx >>3 ),1 << (slot_idx %32 ));
Greg Kroah-Hartman
maintainerPATCH 80/101 target/iscsi: Fix double free in lio_target_tiqn_addtpg()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit a91918cd3ea11f91c68e08e1e8ce1b560447a80e upstream.
This iscsit_tpg_add_portal_group() function is only called from lio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.
--- drivers/target/iscsi/iscsi_target_tpg.c | 1 - 1 file changed, 1 deletion(-)
drivers/target/iscsi/iscsi_target_tpg.c +0 -1
@@ -260,7 +260,6 @@ err_out:iscsi_release_param_list (tpg->param_list); tpg->param_list =NULL ; } -kfree (tpg);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 81/101 irqchip/bcm7038-l1: Implement irq_cpu_offline() callback
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit 34c535793bcbf9263cf22f8a52101f796cdfab8e upstream.
We did not implement an irq_cpu_offline callback for our irqchip, yet we support setting a given IRQ's affinity. This resulted in interrupts whose affinity mask included CPUs being taken offline not to work correctly once the CPU had been put offline.
--- drivers/irqchip/irq-bcm7038-l1.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/irqchip/irq-bcm7038-l1.c +26 -0
@@ -216,6 +216,31 @@ static int bcm7038_l1_set_affinity(strucreturn 0 ; } +static void bcm7038_l1_cpu_offline (struct irq_data *d) +{ +struct cpumask *mask =irq_data_get_affinity_mask (d); +int cpu =smp_processor_id (); +cpumask_t new_affinity; + +/* This CPU was not on the affinity mask */ +if (!cpumask_test_cpu (cpu, mask)) +return ; + +if (cpumask_weight (mask) >1 ) { +/* +* Multiple CPU affinity, remove this CPU from the affinity +* mask +*/ +cpumask_copy (&new_affinity, mask); +cpumask_clear_cpu (cpu, &new_affinity); + }else { +/* Only CPU, put on the lowest online CPU */ +cpumask_clear (&new_affinity); +cpumask_set_cpu (cpumask_first (cpu_online_mask), &new_affinity); + } +irq_set_affinity_locked (d, &new_affinity, false); +} +static int __init bcm7038_l1_init_one (struct device_node *dn,unsigned int idx,struct bcm7038_l1_chip *intc)
@@ -267,6 +292,7 @@ static struct irq_chip bcm7038_l1_irq_ch .irq_mask = bcm7038_l1_mask, .irq_unmask = bcm7038_l1_unmask, .irq_set_affinity = bcm7038_l1_set_affinity, + .irq_cpu_offline = bcm7038_l1_cpu_offline, }; static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
Greg Kroah-Hartman
maintainerPATCH 82/101 PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
commit bed570307ed78f21b77cb04a1df781dee4a8f05a upstream.
I noticed some wakeirq flakeyness with consumer drivers not using autosuspend. For drivers not using autosuspend, the wakeirq may never get unmasked in rpm_suspend() because of irq desc->depth.
We are configuring dedicated wakeirqs to start with IRQ_NOAUTOEN as we naturally don't want them running until rpm_suspend() is called.
However, when a consumer driver initially calls pm_runtime_get(), we now wrongly start with disable_irq_nosync() call on the dedicated wakeirq that is disabled to start with.
This causes desc->depth to toggle between 1 and 2 instead of the usual 0 and 1. This can prevent enable_irq() from unmasking the wakeirq as that only happens at desc->depth 1.
This does not necessarily show up with drivers using autosuspend as there is time for disable_irq_nosync() before rpm_suspend() gets called after the autosuspend timeout.
Let's fix the issue by adding wirq->status that lazily gets set on the first rpm_suspend(). We also need PM runtime core private functions for dev_pm_enable_wake_irq_check() and dev_pm_disable_wake_irq_check() so we can enable the dedicated wakeirq on the first rpm_suspend().
While at it, let's also fix the comments for dev_pm_enable_wake_irq() and dev_pm_disable_wake_irq(). Those can still be used by the consumer drivers as needed because the IRQ core manages the interrupt usecount for us.
--- drivers/base/power/power.h | 19 ++++++++++ drivers/base/power/runtime.c | 8 ++-- drivers/base/power/wakeirq.c | 76 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 88 insertions(+), 15 deletions(-)
drivers/base/power/power.h +18 -1
@@ -20,14 +20,22 @@ static inline void pm_runtime_early_initextern void pm_runtime_init (struct device *dev);extern void pm_runtime_remove (struct device *dev); +#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0) +#define WAKE_IRQ_DEDICATED_MANAGED BIT(1) +#define WAKE_IRQ_DEDICATED_MASK (WAKE_IRQ_DEDICATED_ALLOCATED | \ + WAKE_IRQ_DEDICATED_MANAGED) +struct wake_irq {struct device *dev; +unsigned int status;int irq; -bool dedicated_irq:1 ; };extern void dev_pm_arm_wake_irq (struct wake_irq *wirq);extern void dev_pm_disarm_wake_irq (struct wake_irq *wirq); +extern void dev_pm_enable_wake_irq_check (struct device *dev, +bool can_change_status); +extern void dev_pm_disable_wake_irq_check (struct device *dev);#ifdef CONFIG_PM_SLEEP
@@ -102,6 +110,15 @@ static inline void dev_pm_disarm_wake_ir { } +static inline void dev_pm_enable_wake_irq_check (struct device *dev, +bool can_change_status) +{ +} + +static inline void dev_pm_disable_wake_irq_check (struct device *dev) +{ +} +#endif #ifdef CONFIG_PM_SLEEP
drivers/base/power/runtime.c +4 -4
@@ -515,7 +515,7 @@ static int rpm_suspend(struct device *de callback =RPM_GET_CALLBACK (dev, runtime_suspend); -dev_pm_enable_wake_irq (dev); +dev_pm_enable_wake_irq_check (dev, true); retval =rpm_callback (callback, dev);if (retval) goto fail;
@@ -554,7 +554,7 @@ static int rpm_suspend(struct device *dereturn retval; fail: -dev_pm_disable_wake_irq (dev); +dev_pm_disable_wake_irq_check (dev);__update_runtime_status (dev,RPM_ACTIVE ); dev->power.deferred_resume = false;wake_up_all (&dev->power.wait_queue);
@@ -737,12 +737,12 @@ static int rpm_resume(struct device *dev callback =RPM_GET_CALLBACK (dev, runtime_resume); -dev_pm_disable_wake_irq (dev); +dev_pm_disable_wake_irq_check (dev); retval =rpm_callback (callback, dev);if (retval) {__update_runtime_status (dev,RPM_SUSPENDED );pm_runtime_cancel_pending (dev); -dev_pm_enable_wake_irq (dev); +dev_pm_enable_wake_irq_check (dev, false); }else { no_callback:__update_runtime_status (dev,RPM_ACTIVE );
drivers/base/power/wakeirq.c +66 -10
123 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 83/101 mmc: mmc_test: Uninitialized return value
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 16652a936e96f5dae53c3fbd38a570497baadaa8 upstream.
We never set "ret" to RESULT_OK.
--- drivers/mmc/card/mmc_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/mmc_test.c +1 -1
@@ -791,7 +791,7 @@ static int mmc_test_nonblock_transfer(ststruct mmc_async_req *cur_areq = &test_areq[0 ].areq;struct mmc_async_req *other_areq = &test_areq[1 ].areq;int i; -int ret; +int ret =RESULT_OK ; test_areq[0 ].test = test; test_areq[1 ].test = test;
Greg Kroah-Hartman
maintainerPATCH 84/101 s390/crypto: unlock on error in prng_tdes_read()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 9e6e7c74315095fd40f41003850690c711e44420 upstream.
We added some new locking but forgot to unlock on error.
--- arch/s390/crypto/prng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/crypto/prng.c +4 -2
@@ -565,8 +565,10 @@ static ssize_t prng_tdes_read(struct fil prng_data->prngws.byte_counter += n; prng_data->prngws.reseed_counter += n; -if (copy_to_user (ubuf, prng_data->buf, chunk)) -return -EFAULT ; +if (copy_to_user (ubuf, prng_data->buf, chunk)) { + ret = -EFAULT ; +break ; + } nbytes -= chunk; ret += chunk;
Greg Kroah-Hartman
maintainerPATCH 85/101 crypto: arm64/sha2-ce - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 174122c39c369ed924d2608fc0be0171997ce800 upstream.
The SHA256 digest is an array of 8 32-bit quantities, so we should refer to them as such in order for this code to work correctly when built for big endian. So replace 16 byte scalar loads and stores with 4x32 vector ones where appropriate.
--- arch/arm64/crypto/sha2-ce-core.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/crypto/sha2-ce-core.S +2 -2
@@ -85,7 +85,7 @@ ENTRY(sha2_ce_transform) ld1 {v12.4s-v15.4s}, [x8] /* load state */ - ldp dga, dgb, [x0] + ld1 {dgav.4s, dgbv.4s}, [x0] /* load sha256_ce_state::finalize */ ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
@@ -148,6 +148,6 @@ CPU_LE( rev32 v19.16b, v19.16b ) b 1b /* store new state */ -3: stp dga, dgb, [x0] +3: st1 {dgav.4s, dgbv.4s}, [x0] ret ENDPROC(sha2_ce_transform)
Greg Kroah-Hartman
maintainerPATCH 86/101 crypto: arm64/ghash-ce - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 9c433ad5083fd4a4a3c721d86cbfbd0b2a2326a5 upstream.
The GHASH key and digest are both pairs of 64-bit quantities, but the GHASH code does not always refer to them as such, causing failures when built for big endian. So replace the 16x1 loads and stores with 2x8 ones.
--- arch/arm64/crypto/ghash-ce-core.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/crypto/ghash-ce-core.S +3 -3
@@ -29,8 +29,8 @@ * struct ghash_key const *k, const char *head) */ ENTRY(pmull_ghash_update) - ld1 {SHASH.16b}, [x3] - ld1 {XL.16b}, [x1] + ld1 {SHASH.2d}, [x3] + ld1 {XL.2d}, [x1] movi MASK.16b, #0xe1 ext SHASH2.16b, SHASH.16b, SHASH.16b, #8 shl MASK.2d, MASK.2d, #57
@@ -74,6 +74,6 @@ CPU_LE( rev64 T1.16b, T1.16b ) cbnz w0, 0b - st1 {XL.16b}, [x1] + st1 {XL.2d}, [x1] ret ENDPROC(pmull_ghash_update)
Greg Kroah-Hartman
maintainerPATCH 87/101 crypto: arm/aes-ce - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 58010fa6f71c9577922b22e46014b95a4ec80fa0 upstream.
The AES key schedule generation is mostly endian agnostic, with the exception of the rotation and the incorporation of the round constant at the start of each round. So implement a big endian specific version of that part to make the whole routine big endian compatible.
--- arch/arm/crypto/aes-ce-glue.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/crypto/aes-ce-glue.c +5 -0
@@ -87,8 +87,13 @@ static int ce_aes_expandkey(struct cryptu32 *rki = ctx->key_enc + (i * kwords);u32 *rko = rki + kwords; +#ifndef CONFIG_CPU_BIG_ENDIAN rko[0 ] =ror32 (ce_aes_sub (rki[kwords -1 ]),8 ); rko[0 ] = rko[0 ] ^ rki[0 ] ^ rcon[i]; +#else + rko[0 ] =rol32 (ce_aes_sub (rki[kwords -1 ]),8 ); + rko[0 ] = rko[0 ] ^ rki[0 ] ^ (rcon[i] <<24 ); +#endif rko[1 ] = rko[0 ] ^ rki[1 ]; rko[2 ] = rko[1 ] ^ rki[2 ]; rko[3 ] = rko[2 ] ^ rki[3 ];
Greg Kroah-Hartman
maintainerPATCH 88/101 crypto: arm64/aes-ccm-ce: fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 56e4e76c68fcb51547b5299e5b66a135935ff414 upstream.
The AES-CCM implementation that uses ARMv8 Crypto Extensions instructions refers to the AES round keys as pairs of 64-bit quantities, which causes failures when building the code for big endian. In addition, it byte swaps the input counter unconditionally, while this is only required for little endian builds. So fix both issues.
--- arch/arm64/crypto/aes-ce-ccm-core.S | 53 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 26 deletions(-)
arch/arm64/crypto/aes-ce-ccm-core.S +27 -26
@@ -9,6 +9,7 @@ */ #include <linux/linkage.h> +#include <asm/assembler.h> .text .arch armv8-a+crypto
@@ -19,7 +20,7 @@ */ ENTRY(ce_aes_ccm_auth_data) ldr w8, [x3] /* leftover from prev round? */ - ld1 {v0.2d}, [x0] /* load mac */ + ld1 {v0.16b}, [x0] /* load mac */ cbz w8, 1f sub w8, w8, #16 eor v1.16b, v1.16b, v1.16b
@@ -31,7 +32,7 @@ ENTRY(ce_aes_ccm_auth_data) beq 8f /* out of input? */ cbnz w8, 0b eor v0.16b, v0.16b, v1.16b -1: ld1 {v3.2d}, [x4] /* load first round key */ +1: ld1 {v3.16b}, [x4] /* load first round key */ prfm pldl1strm, [x1] cmp w5, #12 /* which key size? */ add x6, x4, #16
@@ -41,17 +42,17 @@ ENTRY(ce_aes_ccm_auth_data) mov v5.16b, v3.16b b 4f 2: mov v4.16b, v3.16b - ld1 {v5.2d}, [x6], #16 /* load 2nd round key */ + ld1 {v5.16b}, [x6], #16 /* load 2nd round key */ 3: aese v0.16b, v4.16b aesmc v0.16b, v0.16b -4: ld1 {v3.2d}, [x6], #16 /* load next round key */ +4: ld1 {v3.16b}, [x6], #16 /* load next round key */ aese v0.16b, v5.16b aesmc v0.16b, v0.16b -5: ld1 {v4.2d}, [x6], #16 /* load next round key */ +5: ld1 {v4.16b}, [x6], #16 /* load next round key */ subs w7, w7, #3 aese v0.16b, v3.16b aesmc v0.16b, v0.16b - ld1 {v5.2d}, [x6], #16 /* load next round key */ + ld1 {v5.16b}, [x6], #16 /* load next round key */ bpl 3b aese v0.16b, v4.16b subs w2, w2, #16 /* last data? */
@@ -60,7 +61,7 @@ ENTRY(ce_aes_ccm_auth_data) ld1 {v1.16b}, [x1], #16 /* load next input block */ eor v0.16b, v0.16b, v1.16b /* xor with mac */ bne 1b -6: st1 {v0.2d}, [x0] /* store mac */ +6: st1 {v0.16b}, [x0] /* store mac */ beq 10f adds w2, w2, #16 beq 10f
@@ -79,7 +80,7 @@ ENTRY(ce_aes_ccm_auth_data) adds w7, w7, #1 bne 9b eor v0.16b, v0.16b, v1.16b - st1 {v0.2d}, [x0] + st1 {v0.16b}, [x0] 10: str w8, [x3] ret ENDPROC(ce_aes_ccm_auth_data)
@@ -89,27 +90,27 @@ ENDPROC(ce_aes_ccm_auth_data) * u32 rounds); */ ENTRY(ce_aes_ccm_final) - ld1 {v3.2d}, [x2], #16 /* load first round key */ - ld1 {v0.2d}, [x0] /* load mac */ + ld1 {v3.16b}, [x2], #16 /* load first round key */ + ld1 {v0.16b}, [x0] /* load mac */ cmp w3, #12 /* which key size? */ sub w3, w3, #2 /* modified # of rounds */ - ld1 {v1.2d}, [x1] /* load 1st ctriv */ + ld1 {v1.16b}, [x1] /* load 1st ctriv */ bmi 0f bne 3f mov v5.16b, v3.16b b 2f 0: mov v4.16b, v3.16b -1: ld1 {v5.2d}, [x2], #16 /* load next round key */ +1: ld1 {v5.16b}, [x2], #16 /* load next round key */ aese v0.16b, v4.16b aesmc v0.16b, v0.16b aese v1.16b, v4.16b aesmc v1.16b, v1.16b -2: ld1 {v3.2d}, [x2], #16 /* load next round key */ +2: ld1 {v3.16b}, [x2], #16 /* load next round key */ aese v0.16b, v5.16b aesmc v0.16b, v0.16b aese v1.16b, v5.16b aesmc v1.16b, v1.16b -3: ld1 {v4.2d}, [x2], #16 /* load next round key */ +3: ld1 {v4.16b}, [x2], #16 /* load next round key */ subs w3, w3, #3 aese v0.16b, v3.16b aesmc v0.16b, v0.16b
@@ -120,47 +121,47 @@ ENTRY(ce_aes_ccm_final) aese v1.16b, v4.16b /* final round key cancels out */ eor v0.16b, v0.16b, v1.16b /* en-/decrypt the mac */ - st1 {v0.2d}, [x0] /* store result */ + st1 {v0.16b}, [x0] /* store result */ ret ENDPROC(ce_aes_ccm_final) .macro aes_ccm_do_crypt,enc ldr x8, [x6, #8] /* load lower ctr */ - ld1 {v0.2d}, [x5] /* load mac */ - rev x8, x8 /* keep swabbed ctr in reg */ + ld1 {v0.16b}, [x5] /* load mac */ +CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */ 0: /* outer loop */ - ld1 {v1.1d}, [x6] /* load upper ctr */ + ld1 {v1.8b}, [x6] /* load upper ctr */ prfm pldl1strm, [x1] add x8, x8, #1 rev x9, x8 cmp w4, #12 /* which key size? */ sub w7, w4, #2 /* get modified # of rounds */ ins v1.d[1], x9 /* no carry in lower ctr */ - ld1 {v3.2d}, [x3] /* load first round key */ + ld1 {v3.16b}, [x3] /* load first round key */ add x10, x3, #16 bmi 1f bne 4f mov v5.16b, v3.16b b 3f 1: mov v4.16b, v3.16b - ld1 {v5.2d}, [x10], #16 /* load 2nd round key */ + ld1 {v5.16b}, [x10], #16 /* load 2nd round key */ 2: /* inner loop: 3 rounds, 2x interleaved */ aese v0.16b, v4.16b aesmc v0.16b, v0.16b aese v1.16b, v4.16b aesmc v1.16b, v1.16b -3: ld1 {v3.2d}, [x10], #16 /* load next round key */ +3: ld1 {v3.16b}, [x10], #16 /* load next round key */ aese v0.16b, v5.16b aesmc v0.16b, v0.16b aese v1.16b, v5.16b aesmc v1.16b, v1.16b -4: ld1 {v4.2d}, [x10], #16 /* load next round key */ +4: ld1 {v4.16b}, [x10], #16 /* load next round key */ subs w7, w7, #3 aese v0.16b, v3.16b aesmc v0.16b, v0.16b aese v1.16b, v3.16b aesmc v1.16b, v1.16b - ld1 {v5.2d}, [x10], #16 /* load next round key */ + ld1 {v5.16b}, [x10], #16 /* load next round key */ bpl 2b aese v0.16b, v4.16b aese v1.16b, v4.16b
@@ -177,14 +178,14 @@ ENDPROC(ce_aes_ccm_final) eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */ st1 {v1.16b}, [x0], #16 /* write output block */ bne 0b - rev x8, x8 - st1 {v0.2d}, [x5] /* store mac */ +CPU_LE( rev x8, x8 ) + st1 {v0.16b}, [x5] /* store mac */ str x8, [x6, #8] /* store lsb end of ctr (BE) */ 5: ret 6: eor v0.16b, v0.16b, v5.16b /* final round mac */ eor v1.16b, v1.16b, v5.16b /* final round enc */ - st1 {v0.2d}, [x5] /* store mac */ + st1 {v0.16b}, [x5] /* store mac */ add w2, w2, #16 /* process partial tail block */ 7: ldrb w9, [x1], #1 /* get 1 byte of input */ umov w6, v1.b[0] /* get top crypted ctr byte */
Greg Kroah-Hartman
maintainerPATCH 89/101 crypto: arm64/aes-neon - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit a2c435cc99862fd3d165e1b66bf48ac72c839c62 upstream.
The AES implementation using pure NEON instructions relies on the generic AES key schedule generation routines, which store the round keys as arrays of 32-bit quantities stored in memory using native endianness. This means we should refer to these round keys using 4x4 loads rather than 16x1 loads. In addition, the ShiftRows tables are loading using a single scalar load, which is also affected by endianness, so emit these tables in the correct order depending on whether we are building for big endian or not.
--- arch/arm64/crypto/aes-neon.S | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
arch/arm64/crypto/aes-neon.S +15 -10
@@ -9,6 +9,7 @@ */ #include <linux/linkage.h> +#include <asm/assembler.h> #define AES_ENTRY(func) ENTRY(neon_ ## func) #define AES_ENDPROC(func) ENDPROC(neon_ ## func)
@@ -83,13 +84,13 @@ .endm .macro do_block, enc, in, rounds, rk, rkp, i - ld1 {v15.16b}, [\rk] + ld1 {v15.4s}, [\rk] add \rkp, \rk, #16 mov \i, \rounds 1111: eor \in\().16b, \in\().16b, v15.16b /* ^round key */ tbl \in\().16b, {\in\().16b}, v13.16b /* ShiftRows */ sub_bytes \in - ld1 {v15.16b}, [\rkp], #16 + ld1 {v15.4s}, [\rkp], #16 subs \i, \i, #1 beq 2222f .if \enc == 1
@@ -229,7 +230,7 @@ .endm .macro do_block_2x, enc, in0, in1 rounds, rk, rkp, i - ld1 {v15.16b}, [\rk] + ld1 {v15.4s}, [\rk] add \rkp, \rk, #16 mov \i, \rounds 1111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */
@@ -237,7 +238,7 @@ sub_bytes_2x \in0, \in1 tbl \in0\().16b, {\in0\().16b}, v13.16b /* ShiftRows */ tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */ - ld1 {v15.16b}, [\rkp], #16 + ld1 {v15.4s}, [\rkp], #16 subs \i, \i, #1 beq 2222f .if \enc == 1
@@ -254,7 +255,7 @@ .endm .macro do_block_4x, enc, in0, in1, in2, in3, rounds, rk, rkp, i - ld1 {v15.16b}, [\rk] + ld1 {v15.4s}, [\rk] add \rkp, \rk, #16 mov \i, \rounds 1111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */
@@ -266,7 +267,7 @@ tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */ tbl \in2\().16b, {\in2\().16b}, v13.16b /* ShiftRows */ tbl \in3\().16b, {\in3\().16b}, v13.16b /* ShiftRows */ - ld1 {v15.16b}, [\rkp], #16 + ld1 {v15.4s}, [\rkp], #16 subs \i, \i, #1 beq 2222f .if \enc == 1
@@ -306,12 +307,16 @@ .text .align 4 .LForward_ShiftRows: - .byte 0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3 - .byte 0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb +CPU_LE( .byte 0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3 ) +CPU_LE( .byte 0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb ) +CPU_BE( .byte 0xb, 0x6, 0x1, 0xc, 0x7, 0x2, 0xd, 0x8 ) +CPU_BE( .byte 0x3, 0xe, 0x9, 0x4, 0xf, 0xa, 0x5, 0x0 ) .LReverse_ShiftRows: - .byte 0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb - .byte 0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3 +CPU_LE( .byte 0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb ) +CPU_LE( .byte 0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3 ) +CPU_BE( .byte 0x3, 0x6, 0x9, 0xc, 0xf, 0x2, 0x5, 0x8 ) +CPU_BE( .byte 0xb, 0xe, 0x1, 0x4, 0x7, 0xa, 0xd, 0x0 ) .LForward_Sbox: .byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5
Greg Kroah-Hartman
maintainerPATCH 90/101 crypto: arm64/sha1-ce - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit ee71e5f1e7d25543ee63a80451871f8985b8d431 upstream.
The SHA1 digest is an array of 5 32-bit quantities, so we should refer to them as such in order for this code to work correctly when built for big endian. So replace 16 byte scalar loads and stores with 4x4 vector ones where appropriate.
--- arch/arm64/crypto/sha1-ce-core.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/crypto/sha1-ce-core.S +2 -2
@@ -78,7 +78,7 @@ ENTRY(sha1_ce_transform) ld1r {k3.4s}, [x6] /* load state */ - ldr dga, [x0] + ld1 {dgav.4s}, [x0] ldr dgb, [x0, #16] /* load sha1_ce_state::finalize */
@@ -144,7 +144,7 @@ CPU_LE( rev32 v11.16b, v11.16b ) b 1b /* store new state */ -3: str dga, [x0] +3: st1 {dgav.4s}, [x0] str dgb, [x0, #16] ret ENDPROC(sha1_ce_transform)
Greg Kroah-Hartman
maintainerPATCH 91/101 crypto: arm64/aes-xts-ce: fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit caf4b9e2b326cc2a5005a5c557274306536ace61 upstream.
Emit the XTS tweak literal constants in the appropriate order for a single 128-bit scalar literal load.
--- arch/arm64/crypto/aes-ce.S | 1 + arch/arm64/crypto/aes-modes.S | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm64/crypto/aes-ce.S +1 -0
@@ -10,6 +10,7 @@ */ #include <linux/linkage.h> +#include <asm/assembler.h> #define AES_ENTRY(func) ENTRY(ce_ ## func) #define AES_ENDPROC(func) ENDPROC(ce_ ## func)
arch/arm64/crypto/aes-modes.S +2 -1
@@ -386,7 +386,8 @@ AES_ENDPROC(aes_ctr_encrypt) .endm .Lxts_mul_x: - .word 1, 0, 0x87, 0 +CPU_LE( .quad 1, 0x87 ) +CPU_BE( .quad 0x87, 1 ) AES_ENTRY(aes_xts_encrypt) FRAME_PUSH
Greg Kroah-Hartman
maintainerPATCH 92/101 crypto: arm64/aes-ce - fix for big endian
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 1803b9a52c4e5a5dbb8a27126f6bc06939359753 upstream.
The core AES cipher implementation that uses ARMv8 Crypto Extensions instructions erroneously loads the round keys as 64-bit quantities, which causes the algorithm to fail when built for big endian. In addition, the key schedule generation routine fails to take endianness into account as well, when loading the combining the input key with the round constants. So fix both issues.
--- arch/arm64/crypto/aes-ce-cipher.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
arch/arm64/crypto/aes-ce-cipher.c +15 -10
@@ -47,24 +47,24 @@ static void aes_cipher_encrypt(struct crkernel_neon_begin_partial (4 ); __asm__(" ld1 {v0.16b}, %[in] ;" -" ld1 {v1.2d}, [%[key]], #16 ;" +" ld1 {v1.16b}, [%[key]], #16 ;" " cmp %w[rounds], #10 ;" " bmi 0f ;" " bne 3f ;" " mov v3.16b, v1.16b ;" " b 2f ;" "0: mov v2.16b, v1.16b ;" -" ld1 {v3.2d}, [%[key]], #16 ;" +" ld1 {v3.16b}, [%[key]], #16 ;" "1: aese v0.16b, v2.16b ;" " aesmc v0.16b, v0.16b ;" -"2: ld1 {v1.2d}, [%[key]], #16 ;" +"2: ld1 {v1.16b}, [%[key]], #16 ;" " aese v0.16b, v3.16b ;" " aesmc v0.16b, v0.16b ;" -"3: ld1 {v2.2d}, [%[key]], #16 ;" +"3: ld1 {v2.16b}, [%[key]], #16 ;" " subs %w[rounds], %w[rounds], #3 ;" " aese v0.16b, v1.16b ;" " aesmc v0.16b, v0.16b ;" -" ld1 {v3.2d}, [%[key]], #16 ;" +" ld1 {v3.16b}, [%[key]], #16 ;" " bpl 1b ;" " aese v0.16b, v2.16b ;" " eor v0.16b, v0.16b, v3.16b ;"
@@ -92,24 +92,24 @@ static void aes_cipher_decrypt(struct crkernel_neon_begin_partial (4 ); __asm__(" ld1 {v0.16b}, %[in] ;" -" ld1 {v1.2d}, [%[key]], #16 ;" +" ld1 {v1.16b}, [%[key]], #16 ;" " cmp %w[rounds], #10 ;" " bmi 0f ;" " bne 3f ;" " mov v3.16b, v1.16b ;" " b 2f ;" "0: mov v2.16b, v1.16b ;" -" ld1 {v3.2d}, [%[key]], #16 ;" +" ld1 {v3.16b}, [%[key]], #16 ;" "1: aesd v0.16b, v2.16b ;" " aesimc v0.16b, v0.16b ;" -"2: ld1 {v1.2d}, [%[key]], #16 ;" +"2: ld1 {v1.16b}, [%[key]], #16 ;" " aesd v0.16b, v3.16b ;" " aesimc v0.16b, v0.16b ;" -"3: ld1 {v2.2d}, [%[key]], #16 ;" +"3: ld1 {v2.16b}, [%[key]], #16 ;" " subs %w[rounds], %w[rounds], #3 ;" " aesd v0.16b, v1.16b ;" " aesimc v0.16b, v0.16b ;" -" ld1 {v3.2d}, [%[key]], #16 ;" +" ld1 {v3.16b}, [%[key]], #16 ;" " bpl 1b ;" " aesd v0.16b, v2.16b ;" " eor v0.16b, v0.16b, v3.16b ;"
@@ -173,7 +173,12 @@ int ce_aes_expandkey(struct crypto_aes_cu32 *rki = ctx->key_enc + (i * kwords);u32 *rko = rki + kwords; +#ifndef CONFIG_CPU_BIG_ENDIAN rko[0 ] =ror32 (aes_sub (rki[kwords -1 ]),8 ) ^ rcon[i] ^ rki[0 ]; +#else + rko[0 ] =rol32 (aes_sub (rki[kwords -1 ]),8 ) ^ (rcon[i] <<24 ) ^ + rki[0 ]; +#endif rko[1 ] = rko[0 ] ^ rki[1 ]; rko[2 ] = rko[1 ] ^ rki[2 ]; rko[3 ] = rko[2 ] ^ rki[3 ];
Greg Kroah-Hartman
maintainerPATCH 93/101 md: MD_RECOVERY_NEEDED is set for mddev->recovery
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaohua Li <[email protected]>
commit 82a301cb0ea2df8a5c88213094a01660067c7fb4 upstream.
removal.")
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -6771,7 +6771,7 @@ static int md_ioctl(struct block_device/* need to ensure recovery thread has run */ wait_event_interruptible_timeout (mddev->sb_wait, !test_bit (MD_RECOVERY_NEEDED , - &mddev->flags), + &mddev->recovery),msecs_to_jiffies (5000 ));if (cmd ==STOP_ARRAY || cmd ==STOP_ARRAY_RO ) {/* Need to flush page cache, and ensure no-one else opens
Greg Kroah-Hartman
maintainerPATCH 94/101 powerpc/pci/rpadlpar: Fix device reference leaks
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 99e5cde5eae78bef95bfe7c16ccda87fb070149b upstream.
Make sure to drop any device reference taken by vio_find_node() when adding and removing virtual I/O slots.
--- drivers/pci/hotplug/rpadlpar_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/pci/hotplug/rpadlpar_core.c +9 -1
@@ -258,8 +258,13 @@ static int dlpar_add_phb(char *drc_name,static int dlpar_add_vio_slot (char *drc_name,struct device_node *dn) { -if (vio_find_node (dn)) +struct vio_dev *vio_dev; + + vio_dev =vio_find_node (dn); +if (vio_dev) { +put_device (&vio_dev->dev);return -EINVAL ; + }if (!vio_register_device_node (dn)) { printk(KERN_ERR
@@ -335,6 +340,9 @@ static int dlpar_remove_vio_slot(char *dreturn -EINVAL ;vio_unregister_device (vio_dev); + +put_device (&vio_dev->dev); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 95/101 staging: comedi: dt282x: tidy up register bit defines
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: H Hartley Sweeten <[email protected]>
commit f6b1160eb27f990cc1c48b67a5f83cb63115284e upstream.
Arnd Bergmann pointed out that gcc-6 warns about passing negative signed integer into swab16() due to the macro expansion of 'outw'.
It appears that the register map constants are causing the warnings. Actually, it might just be the (1 << 15) ones...
Convert all the constants as suggested by checkpatch.pl:
CHECK: Prefer using the BIT macro
The BIT() macro will make all the constants explicitly 'unsigned', which helps to avoid the warning.
Fix the, unsused, DT2821_CHANCSR_PRESLA() macro. The "Present List Address" (PRESLA) bits in the CHANCSR register are read only. This define was meant to extract the bits from the read value.
--- drivers/staging/comedi/drivers/dt282x.c | 65 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 32 deletions(-)
drivers/staging/comedi/drivers/dt282x.c +33 -32
@@ -69,48 +69,49 @@* Register map */ #define DT2821_ADCSR_REG 0x00 -#define DT2821_ADCSR_ADERR (1 << 15) -#define DT2821_ADCSR_ADCLK (1 << 9) -#define DT2821_ADCSR_MUXBUSY (1 << 8) -#define DT2821_ADCSR_ADDONE (1 << 7) -#define DT2821_ADCSR_IADDONE (1 << 6) +#define DT2821_ADCSR_ADERR BIT(15) +#define DT2821_ADCSR_ADCLK BIT(9) +#define DT2821_ADCSR_MUXBUSY BIT(8) +#define DT2821_ADCSR_ADDONE BIT(7) +#define DT2821_ADCSR_IADDONE BIT(6)#define DT2821_ADCSR_GS (x) (((x) & 0x3) << 4)#define DT2821_ADCSR_CHAN (x) (((x) & 0xf) << 0)#define DT2821_CHANCSR_REG 0x02 -#define DT2821_CHANCSR_LLE (1 << 15) -#define DT2821_CHANCSR_PRESLA (x) (((x) & 0xf) >> 8) +#define DT2821_CHANCSR_LLE BIT(15) +#define DT2821_CHANCSR_TO_PRESLA (x) (((x) >> 8) & 0xf)#define DT2821_CHANCSR_NUMB (x) ((((x) - 1) & 0xf) << 0)#define DT2821_ADDAT_REG 0x04#define DT2821_DACSR_REG 0x06 -#define DT2821_DACSR_DAERR (1 << 15) +#define DT2821_DACSR_DAERR BIT(15)#define DT2821_DACSR_YSEL (x) ((x) << 9) -#define DT2821_DACSR_SSEL (1 << 8) -#define DT2821_DACSR_DACRDY (1 << 7) -#define DT2821_DACSR_IDARDY (1 << 6) -#define DT2821_DACSR_DACLK (1 << 5) -#define DT2821_DACSR_HBOE (1 << 1) -#define DT2821_DACSR_LBOE (1 << 0) +#define DT2821_DACSR_SSEL BIT(8) +#define DT2821_DACSR_DACRDY BIT(7) +#define DT2821_DACSR_IDARDY BIT(6) +#define DT2821_DACSR_DACLK BIT(5) +#define DT2821_DACSR_HBOE BIT(1) +#define DT2821_DACSR_LBOE BIT(0)#define DT2821_DADAT_REG 0x08#define DT2821_DIODAT_REG 0x0a#define DT2821_SUPCSR_REG 0x0c -#define DT2821_SUPCSR_DMAD (1 << 15) -#define DT2821_SUPCSR_ERRINTEN (1 << 14) -#define DT2821_SUPCSR_CLRDMADNE (1 << 13) -#define DT2821_SUPCSR_DDMA (1 << 12) -#define DT2821_SUPCSR_DS_PIO (0 << 10) -#define DT2821_SUPCSR_DS_AD_CLK (1 << 10) -#define DT2821_SUPCSR_DS_DA_CLK (2 << 10) -#define DT2821_SUPCSR_DS_AD_TRIG (3 << 10) -#define DT2821_SUPCSR_BUFFB (1 << 9) -#define DT2821_SUPCSR_SCDN (1 << 8) -#define DT2821_SUPCSR_DACON (1 << 7) -#define DT2821_SUPCSR_ADCINIT (1 << 6) -#define DT2821_SUPCSR_DACINIT (1 << 5) -#define DT2821_SUPCSR_PRLD (1 << 4) -#define DT2821_SUPCSR_STRIG (1 << 3) -#define DT2821_SUPCSR_XTRIG (1 << 2) -#define DT2821_SUPCSR_XCLK (1 << 1) -#define DT2821_SUPCSR_BDINIT (1 << 0) +#define DT2821_SUPCSR_DMAD BIT(15) +#define DT2821_SUPCSR_ERRINTEN BIT(14) +#define DT2821_SUPCSR_CLRDMADNE BIT(13) +#define DT2821_SUPCSR_DDMA BIT(12) +#define DT2821_SUPCSR_DS (x) (((x) & 0x3) << 10) +#define DT2821_SUPCSR_DS_PIO DT2821_SUPCSR_DS(0) +#define DT2821_SUPCSR_DS_AD_CLK DT2821_SUPCSR_DS(1) +#define DT2821_SUPCSR_DS_DA_CLK DT2821_SUPCSR_DS(2) +#define DT2821_SUPCSR_DS_AD_TRIG DT2821_SUPCSR_DS(3) +#define DT2821_SUPCSR_BUFFB BIT(9) +#define DT2821_SUPCSR_SCDN BIT(8) +#define DT2821_SUPCSR_DACON BIT(7) +#define DT2821_SUPCSR_ADCINIT BIT(6) +#define DT2821_SUPCSR_DACINIT BIT(5) +#define DT2821_SUPCSR_PRLD BIT(4) +#define DT2821_SUPCSR_STRIG BIT(3) +#define DT2821_SUPCSR_XTRIG BIT(2) +#define DT2821_SUPCSR_XCLK BIT(1) +#define DT2821_SUPCSR_BDINIT BIT(0)#define DT2821_TMRCTR_REG 0x0estatic const struct comedi_lrange range_dt282x_ai_lo_bipolar = {
Greg Kroah-Hartman
maintainerPATCH 96/101 cred/userns: define current_user_ns() as a function
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 0335695dfa4df01edff5bb102b9a82a0668ee51e upstream.
The current_user_ns() macro currently returns &init_user_ns when user namespaces are disabled, and that causes several warnings when building with gcc-6.0 in code that compares the result of the macro to &init_user_ns itself:
fs/xfs/xfs_ioctl.c: In function 'xfs_ioctl_setattr_check_projid':
fs/xfs/xfs_ioctl.c:1249:22: error: self-comparison always evaluates to true [-Werror=tautological-compare]
if (current_user_ns() == &init_user_ns)
This is a legitimate warning in principle, but here it isn't really helpful, so I'm reprasing the definition in a way that shuts up the warning. Apparently gcc only warns when comparing identical literals, but it can figure out that the result of an inline function can be identical to a constant expression in order to optimize a condition yet not warn about the fact that the condition is known at compile time. This is exactly what we want here, and it looks reasonable because we generally prefer inline functions over macros anyway.
--- include/linux/capability.h | 2 -- include/linux/cred.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-)
include/linux/capability.h +0 -2
@@ -40,8 +40,6 @@ struct inode;struct dentry ;struct user_namespace ; -struct user_namespace *current_user_ns (void ); -extern const kernel_cap_t __cap_empty_set;extern const kernel_cap_t __cap_init_eff_set;
include/linux/cred.h +4 -1
@@ -377,7 +377,10 @@ extern struct user_namespace init_user_n#ifdef CONFIG_USER_NS #define current_user_ns () (current_cred_xxx(user_ns))#else -#define current_user_ns () (&init_user_ns) +static inline struct user_namespace *current_user_ns (void ) +{ +return &init_user_ns; +}#endif
Greg Kroah-Hartman
maintainerPATCH 97/101 net: ti: cpmac: Fix compiler warning due to type confusion
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 2f5281ba2a8feaf6f0aee93356f350855bb530fc upstream.
cpmac_start_xmit() used the max() macro on skb->len (an unsigned int) and ETH_ZLEN (a signed int literal). This led to the following compiler warning:
In file included from include/linux/list.h:8:0,
from include/linux/module.h:9,
from drivers/net/ethernet/ti/cpmac.c:19:
drivers/net/ethernet/ti/cpmac.c: In function 'cpmac_start_xmit':
include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
(void) (&_max1 == &_max2); \
^
drivers/net/ethernet/ti/cpmac.c:560:8: note: in expansion of macro 'max'
len = max(skb->len, ETH_ZLEN);
^On top of this, it assigned the result of the max() macro to a signed integer whilst all further uses of it result in it being cast to varying widths of unsigned integer.
Fix this up by using max_t to ensure the comparison is performed as unsigned integers, and for consistency change the type of the len variable to unsigned int.
--- drivers/net/ethernet/ti/cpmac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/cpmac.c +3 -2
@@ -549,7 +549,8 @@ fatal_error:static int cpmac_start_xmit (struct sk_buff *skb,struct net_device *dev) { -int queue, len; +int queue; +unsigned int len;struct cpmac_desc *desc;struct cpmac_priv *priv =netdev_priv (dev);
@@ -559,7 +560,7 @@ static int cpmac_start_xmit(struct sk_buif (unlikely (skb_padto (skb,ETH_ZLEN )))return NETDEV_TX_OK ; - len =max (skb->len,ETH_ZLEN ); + len = max_t(unsigned int, skb->len, ETH_ZLEN); queue =skb_get_queue_mapping (skb);netif_stop_subqueue (dev, queue);
Greg Kroah-Hartman
maintainerPATCH 98/101 net: vxge: avoid unused function warnings
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 57e7c8cef224af166b8ec932b5e383641418c005 upstream.
When CONFIG_PCI_MSI is disabled, we get warnings about unused functions in the vxge driver:
drivers/net/ethernet/neterion/vxge/vxge-main.c:2121:13: warning: 'adaptive_coalesce_tx_interrupts' defined but not used [-Wunused-function] drivers/net/ethernet/neterion/vxge/vxge-main.c:2149:13: warning: 'adaptive_coalesce_rx_interrupts' defined but not used [-Wunused-function]
We could add another #ifdef here, but it's nicer to avoid those warnings for good by converting the existing #ifdef to if(IS_ENABLED()), which has the same effect but provides better compile-time coverage in general, and lets the compiler understand better when the function is intentionally unused.
--- drivers/net/ethernet/neterion/vxge/vxge-main.c | 31 +++++++++---------------- 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/net/ethernet/neterion/vxge/vxge-main.c +12 -19
@@ -2223,8 +2223,6 @@ static irqreturn_t vxge_isr_napi(int irqreturn IRQ_NONE ; } -#ifdef CONFIG_PCI_MSI -static irqreturn_t vxge_tx_msix_handle (int irq,void *dev_id) {struct vxge_fifo *fifo = (struct vxge_fifo *)dev_id;
@@ -2442,16 +2440,13 @@ static void vxge_rem_msix_isr(struct vxgif (vdev->config.intr_type ==MSI_X )pci_disable_msix (vdev->pdev); } -#endif static void vxge_rem_isr (struct vxgedev *vdev) { -#ifdef CONFIG_PCI_MSI -if (vdev->config.intr_type ==MSI_X ) { +if (IS_ENABLED (CONFIG_PCI_MSI ) && + vdev->config.intr_type ==MSI_X ) {vxge_rem_msix_isr (vdev); - } else -#endif -if (vdev->config.intr_type ==INTA ) { + }else if (vdev->config.intr_type ==INTA ) {synchronize_irq (vdev->pdev->irq);free_irq (vdev->pdev->irq, vdev); }
@@ -2460,11 +2455,10 @@ static void vxge_rem_isr(struct vxgedevstatic int vxge_add_isr (struct vxgedev *vdev) {int ret =0 ; -#ifdef CONFIG_PCI_MSI int vp_idx =0 , intr_idx =0 , intr_cnt =0 , msix_idx =0 , irq_req =0 ;int pci_fun =PCI_FUNC (vdev->pdev->devfn); -if (vdev->config.intr_type ==MSI_X ) +if (IS_ENABLED (CONFIG_PCI_MSI ) && vdev->config.intr_type ==MSI_X ) ret =vxge_enable_msix (vdev);if (ret) {
@@ -2475,7 +2469,7 @@ static int vxge_add_isr(struct vxgedev * vdev->config.intr_type =INTA ; } -if (vdev->config.intr_type ==MSI_X ) { +if (IS_ENABLED (CONFIG_PCI_MSI ) && vdev->config.intr_type ==MSI_X ) {for (intr_idx =0 ; intr_idx < (vdev->no_of_vpath *VXGE_HW_VPATH_MSIX_ACTIVE ); intr_idx++) {
@@ -2576,9 +2570,8 @@ static int vxge_add_isr(struct vxgedev * vdev->vxge_entries[intr_cnt].in_use =1 ; vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[0 ]; } -INTA_MODE: -#endif +INTA_MODE:if (vdev->config.intr_type ==INTA ) {snprintf (vdev->desc[0 ],VXGE_INTR_STRLEN ,"%s:vxge:INTA" , vdev->ndev->name);
@@ -3889,12 +3882,12 @@ static void vxge_device_config_init(struif (max_mac_vpath >VXGE_MAX_MAC_ADDR_COUNT ) max_mac_vpath =VXGE_MAX_MAC_ADDR_COUNT ; -#ifndef CONFIG_PCI_MSI -vxge_debug_init (VXGE_ERR , -"%s: This Kernel does not support " -"MSI-X. Defaulting to INTA" ,VXGE_DRIVER_NAME ); - *intr_type =INTA ; -#endif +if (!IS_ENABLED (CONFIG_PCI_MSI )) { +vxge_debug_init (VXGE_ERR , +"%s: This Kernel does not support " +"MSI-X. Defaulting to INTA" ,VXGE_DRIVER_NAME ); + *intr_type =INTA ; + }/* Configure whether MSI-X or IRQL. */ switch (*intr_type) {
Greg Kroah-Hartman
maintainerPATCH 99/101 cx23885-dvb: move initialization of a8293_pdata
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit f0b0faff78c2c2e8efe843de55405a1f0470b8c4 upstream.
Smatch complains about where the au8293_data is placed:
drivers/media/pci/cx23885/cx23885-dvb.c:2174 dvb_register() info: 'a8293_pdata' is not actually initialized (unreached code).
It is not actually expected to have such initialization at
switch {
foo = bar;
case:...
}
Not really sure how gcc does that, but this is something that I would expect that different compilers would do different things.
David Howells checked with the compiler people: it's not really expected to initialise as expected.
So, move the initialization outside the switch(), making smatch to shut up one warning.
--- drivers/media/pci/cx23885/cx23885-dvb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/cx23885/cx23885-dvb.c +4 -2
@@ -2168,11 +2168,12 @@ static int dvb_register(struct cx23885_t } port->i2c_client_tuner = client_tuner;break ; -case CX23885_BOARD_HAUPPAUGE_HVR5525 : -switch (port->nr) { +case CX23885_BOARD_HAUPPAUGE_HVR5525 : {struct m88rs6000t_config m88rs6000t_config;struct a8293_platform_data a8293_pdata = {}; +switch (port->nr) { +/* port b - satellite */ case 1 :/* attach frontend */
@@ -2267,6 +2268,7 @@ static int dvb_register(struct cx23885_tbreak ; }break ; + }default : printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " " isn't supported yet\n",
Greg Kroah-Hartman
maintainerPATCH 101/101 tick/broadcast: Prevent NULL pointer dereference
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit c1a9eeb938b5433947e5ea22f89baff3182e7075 upstream.
When a disfunctional timer, e.g. dummy timer, is installed, the tick core tries to setup the broadcast timer.
If no broadcast device is installed, the kernel crashes with a NULL pointer dereference in tick_broadcast_setup_oneshot() because the function has no sanity check.
--- kernel/time/tick-broadcast.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/time/tick-broadcast.c +3 -0
@@ -871,6 +871,9 @@ void tick_broadcast_setup_oneshot(struct {int cpu =smp_processor_id (); +if (!bc) +return ; +/* Set it up only once ! */ if (bc->event_handler != tick_handle_oneshot_broadcast) {int was_periodic =clockevent_state_periodic (bc);
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.42 release. There are 101 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jan 12 13:15:04 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.42-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America(Silicon Valley) [email protected]
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.42 release. There are 101 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jan 12 13:15:04 UTC 2017. Anything received after that time might be too late.
Build results:
total: 150 pass: 150 fail: 0 Qemu test results: total: 115 pass: 115 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter