5.15.86-rc1 review
Subsystems (11)
Greg Kroah-Hartman
maintainerPATCH 438/731 drivers: dio: fix possible memory leak in dio_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e63e99397b2613d50a5f4f02ed07307e67a190f1 ]
If device_register() returns error, the 'dev' and name needs be freed. Add a release function, and then call put_device() in the error path, so the name is freed in kobject_cleanup() and to the 'dev' is freed in release function.
--- drivers/dio/dio.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dio/dio.c +8 -0
@@ -110,6 +110,12 @@ static char dio_no_name[] = { 0 };#endif /* CONFIG_DIO_CONSTANTS */ +static void dio_dev_release (struct device *dev) +{ + struct dio_dev *ddev = container_of(dev, typeof(struct dio_dev), dev); +kfree (ddev); +} +int __init dio_find (int deviceid) {/* Called to find a DIO device before the full bus scan has run.
@@ -224,6 +230,7 @@ static int __init dio_init(void) dev->bus = &dio_bus; dev->dev.parent = &dio_bus.dev; dev->dev.bus = &dio_bus_type; + dev->dev.release = dio_dev_release; dev->scode = scode; dev->resource.start = pa; dev->resource.end = pa +DIO_SIZE (scode, va);
@@ -251,6 +258,7 @@ static int __init dio_init(void)if (error) {pr_err ("DIO: Error registering device %s\n" , dev->name); +put_device (&dev->dev);continue ; } error =dio_create_sysfs_dev_files (dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 439/731 serial: tegra: Read DMA status before terminating
In reply to Greg Kroah-HartmanFrom: Kartik <[email protected]>
[ Upstream commit 109a951a9f1fd8a34ebd1896cbbd5d5cede880a7 ]
Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.
Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.
--- drivers/tty/serial/serial-tegra.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +4 -2
@@ -619,8 +619,9 @@ static void tegra_uart_stop_tx(struct uart_port *u)if (tup->tx_in_progress !=TEGRA_UART_TX_DMA )return ; -dmaengine_terminate_all (tup->tx_dma_chan); +dmaengine_pause (tup->tx_dma_chan);dmaengine_tx_status (tup->tx_dma_chan, tup->tx_cookie, &state); +dmaengine_terminate_all (tup->tx_dma_chan); count = tup->tx_bytes_requested - state.residue;async_tx_ack (tup->tx_dma_desc);uart_xmit_advance (&tup->uport, count);
@@ -763,8 +764,9 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)return ; } -dmaengine_terminate_all (tup->rx_dma_chan); +dmaengine_pause (tup->rx_dma_chan);dmaengine_tx_status (tup->rx_dma_chan, tup->rx_cookie, &state); +dmaengine_terminate_all (tup->rx_dma_chan);tegra_uart_rx_buffer_push (tup, state.residue); tup->rx_dma_active = false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 440/731 serial: 8250_bcm7271: Fix error handling in brcmuart_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 6a3ff858915fa8ca36c7eb02c87c9181ae2fc333 ]
A problem about 8250_bcm7271 create debugfs failed is triggered with the following log given:
[ 324.516635] debugfs: Directory 'bcm7271-uart' with parent '/' already present!
The reason is that brcmuart_init() returns platform_driver_register() directly without checking its return value, if platform_driver_register() failed, it returns without destroy the newly created debugfs, resulting the debugfs of 8250_bcm7271 can never be created later.
brcmuart_init()
debugfs_create_dir() # create debugfs directory platform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when platform_driver_register() returns error.
--- drivers/tty/serial/8250/8250_bcm7271.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_bcm7271.c +9 -1
@@ -1214,9 +1214,17 @@ static struct platform_driver brcmuart_platform_driver = {static int __init brcmuart_init (void ) { +int ret; + brcmuart_debugfs_root =debugfs_create_dir ( brcmuart_platform_driver.driver.name,NULL ); -return platform_driver_register (&brcmuart_platform_driver); + ret =platform_driver_register (&brcmuart_platform_driver); +if (ret) { +debugfs_remove_recursive (brcmuart_debugfs_root); +return ret; + } + +return 0 ; }module_init (brcmuart_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 441/731 class: fix possible memory leak in __class_register()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8c3e8a6bdb5253b97ad532570f8b5db5f7a06407 ]
If class_add_groups() returns error, the 'cp->subsys' need be unregister, and the 'cp' need be freed.
We can not call kset_unregister() here, because the 'cls' will be freed in callback function class_release() and it's also freed in caller's error path, it will cause double free.
So fix this by calling kobject_del() and kfree_const(name) to cleanup kobject. Besides, call kfree() to free the 'cp'.
Fault injection test can trigger this:
unreferenced object 0xffff888102fa8190 (size 8):
comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 8 bytes):
70 6b 74 63 64 76 64 00 pktcdvd.
backtrace:
[<00000000e7c7703d>] __kmalloc_track_caller+0x1ae/0x320
[<000000005e4d70bc>] kstrdup+0x3a/0x70
[<00000000c2e5e85a>] kstrdup_const+0x68/0x80
[<000000000049a8c7>] kvasprintf_const+0x10b/0x190
[<0000000029123163>] kobject_set_name_vargs+0x56/0x150
[<00000000747219c9>] kobject_set_name+0xab/0xe0
[<0000000005f1ea4e>] __class_register+0x15c/0x49aunreferenced object 0xffff888037274000 (size 1024):
comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 32 bytes):
00 40 27 37 80 88 ff ff 00 40 27 37 80 88 ff ff .@'7.....@'7....
00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
backtrace:
[<00000000151f9600>] kmem_cache_alloc_trace+0x17c/0x2f0
[<00000000ecf3dd95>] __class_register+0x86/0x49a--- drivers/base/class.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/base/class.c +5 -0
@@ -192,6 +192,11 @@ int __class_register(struct class *cls, struct lock_class_key *key) } error =class_add_groups (class_get (cls), cls->class_groups);class_put (cls); +if (error) { +kobject_del (&cp->subsys.kobj); +kfree_const (cp->subsys.kobj.name); +kfree (cp); + }return error; }EXPORT_SYMBOL_GPL (__class_register);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 442/731 vfio: platform: Do not pass return buffer to ACPI _RST method
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit e67e070632a665c932d534b8b800477bb3111449 ]
The ACPI _RST method has no return value, there's no need to pass a return buffer to acpi_evaluate_object().
--- drivers/vfio/platform/vfio_platform_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +1 -2
@@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev, const char **extra_dbg) {#ifdef CONFIG_ACPI -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };struct device *dev = vdev->device;acpi_handle handle =ACPI_HANDLE (dev);acpi_status acpi_ret; - acpi_ret =acpi_evaluate_object (handle,"_RST" ,NULL , &buffer); + acpi_ret =acpi_evaluate_object (handle,"_RST" ,NULL ,NULL );if (ACPI_FAILURE (acpi_ret)) {if (extra_dbg) *extra_dbg =acpi_format_exception (acpi_ret);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 443/731 uio: uio_dmem_genirq: Fix missing unlock in irq configuration
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 9de255c461d1b3f0242b3ad1450c3323a3e00b34 ]
Commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") started calling disable_irq() without holding the spinlock because it can sleep. However, that fix introduced another bug: if interrupt is already disabled and a new disable request comes in, then the spinlock is not unlocked:
root@localhost:~# printf '\x00\x00\x00\x00' > /dev/uio0 root@localhost:~# printf '\x00\x00\x00\x00' > /dev/uio0 root@localhost:~# [ 14.851538] BUG: scheduling while atomic: bash/223/0x00000002 [ 14.851991] Modules linked in: uio_dmem_genirq uio myfpga(OE) bochs drm_vram_helper drm_ttm_helper ttm drm_kms_helper drm snd_pcm ppdev joydev psmouse snd_timer snd e1000fb_sys_fops syscopyarea parport sysfillrect soundcore sysimgblt input_leds pcspkr i2c_piix4 serio_raw floppy evbug qemu_fw_cfg mac_hid pata_acpi ip_tables x_tables autofs4 [last unloaded: parport_pc] [ 14.854206] CPU: 0 PID: 223 Comm: bash Tainted: G OE 6.0.0-rc7 #21 [ 14.854786] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 [ 14.855664] Call Trace: [ 14.855861] <TASK> [ 14.856025] dump_stack_lvl+0x4d/0x67 [ 14.856325] dump_stack+0x14/0x1a [ 14.856583] __schedule_bug.cold+0x4b/0x5c [ 14.856915] __schedule+0xe81/0x13d0 [ 14.857199] ? idr_find+0x13/0x20 [ 14.857456] ? get_work_pool+0x2d/0x50 [ 14.857756] ? __flush_work+0x233/0x280 [ 14.858068] ? __schedule+0xa95/0x13d0 [ 14.858307] ? idr_find+0x13/0x20 [ 14.858519] ? get_work_pool+0x2d/0x50 [ 14.858798] schedule+0x6c/0x100 [ 14.859009] schedule_hrtimeout_range_clock+0xff/0x110 [ 14.859335] ? tty_write_room+0x1f/0x30 [ 14.859598] ? n_tty_poll+0x1ec/0x220 [ 14.859830] ? tty_ldisc_deref+0x1a/0x20 [ 14.860090] schedule_hrtimeout_range+0x17/0x20 [ 14.860373] do_select+0x596/0x840 [ 14.860627] ? __kernel_text_address+0x16/0x50 [ 14.860954] ? poll_freewait+0xb0/0xb0 [ 14.861235] ? poll_freewait+0xb0/0xb0 [ 14.861517] ? rpm_resume+0x49d/0x780 [ 14.861798] ? common_interrupt+0x59/0xa0 [ 14.862127] ? asm_common_interrupt+0x2b/0x40 [ 14.862511] ? __uart_start.isra.0+0x61/0x70 [ 14.862902] ? __check_object_size+0x61/0x280 [ 14.863255] core_sys_select+0x1c6/0x400 [ 14.863575] ? vfs_write+0x1c9/0x3d0 [ 14.863853] ? vfs_write+0x1c9/0x3d0 [ 14.864121] ? _copy_from_user+0x45/0x70 [ 14.864526] do_pselect.constprop.0+0xb3/0xf0 [ 14.864893] ? do_syscall_64+0x6d/0x90 [ 14.865228] ? do_syscall_64+0x6d/0x90 [ 14.865556] __x64_sys_pselect6+0x76/0xa0 [ 14.865906] do_syscall_64+0x60/0x90 [ 14.866214] ? syscall_exit_to_user_mode+0x2a/0x50 [ 14.866640] ? do_syscall_64+0x6d/0x90 [ 14.866972] ? do_syscall_64+0x6d/0x90 [ 14.867286] ? do_syscall_64+0x6d/0x90 [ 14.867626] entry_SYSCALL_64_after_hwframe+0x63/0xcd [...] stripped [ 14.872959] </TASK>
('myfpga' is a simple 'uio_dmem_genirq' driver I wrote to test this)
The implementation of "uio_dmem_genirq" was based on "uio_pdrv_genirq" and it is used in a similar manner to the "uio_pdrv_genirq" driver with respect to interrupt configuration and handling. At the time "uio_dmem_genirq" was introduced, both had the same implementation of the 'uio_info' handlers irqcontrol() and handler(). Then commit 34cb27528398 ("UIO: Fix concurrency issue"), which was only applied to "uio_pdrv_genirq", ended up making them a little different. That commit, among other things, changed disable_irq() to disable_irq_nosync() in the implementation of irqcontrol(). The motivation there was to avoid a deadlock between irqcontrol() and handler(), since it added a spinlock in the irq handler, and disable_irq() waits for the completion of the irq handler.
By changing disable_irq() to disable_irq_nosync() in irqcontrol(), we also avoid the sleeping-while-atomic bug that commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") was trying to fix. Thus, this fixes the missing unlock in irqcontrol() by importing the implementation of irqcontrol() handler from the "uio_pdrv_genirq" driver. In the end, it reverts commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") and change disable_irq() to disable_irq_nosync().
It is worth noting that this still does not address the concurrency issue fixed by commit 34cb27528398 ("UIO: Fix concurrency issue"). It will be addressed separately in the next commits.
Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").
--- drivers/uio/uio_dmem_genirq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/uio/uio_dmem_genirq.c +3 -5
@@ -132,13 +132,11 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)if (irq_on) {if (test_and_clear_bit (0 , &priv->flags))enable_irq (dev_info->irq); -spin_unlock_irqrestore (&priv->lock, flags); }else { -if (!test_and_set_bit (0 , &priv->flags)) { -spin_unlock_irqrestore (&priv->lock, flags); -disable_irq (dev_info->irq); - } +if (!test_and_set_bit (0 , &priv->flags)) +disable_irq_nosync (dev_info->irq); } +spin_unlock_irqrestore (&priv->lock, flags);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 444/731 uio: uio_dmem_genirq: Fix deadlock between irq config and handling
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 118b918018175d9fcd8db667f905012e986cc2c9 ]
This fixes a concurrency issue addressed in commit 34cb27528398 ("UIO: Fix concurrency issue"):
"In a SMP case there was a race condition issue between Uio_pdrv_genirq_irqcontrol() running on one CPU and irq handler on another CPU. Fix it by spin_locking shared resources access inside irq handler."
The implementation of "uio_dmem_genirq" was based on "uio_pdrv_genirq" and it is used in a similar manner to the "uio_pdrv_genirq" driver with respect to interrupt configuration and handling. At the time "uio_dmem_genirq" was merged, both had the same implementation of the 'uio_info' handlers irqcontrol() and handler(), thus, both had the same concurrency issue mentioned by the above commit. However, the above patch was only applied to the "uio_pdrv_genirq" driver.
Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").
--- drivers/uio/uio_dmem_genirq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/uio/uio_dmem_genirq.c +4 -1
@@ -110,8 +110,10 @@ static irqreturn_t uio_dmem_genirq_handler(int irq, struct uio_info *dev_info)* remember the state so we can allow user space to enable it later. */ +spin_lock (&priv->lock);if (!test_and_set_bit (0 , &priv->flags))disable_irq_nosync (irq); +spin_unlock (&priv->lock);return IRQ_HANDLED ; }
@@ -125,7 +127,8 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)* in the interrupt controller, but keep track of the * state to prevent per-irq depth damage. * -* Serialize this operation to support multiple tasks. +* Serialize this operation to support multiple tasks and concurrency +* with irq handler on SMP systems. */ spin_lock_irqsave (&priv->lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 445/731 usb: fotg210-udc: Fix ages old endianness issues
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit 46ed6026ca2181c917c8334a82e3eaf40a6234dd ]
The code in the FOTG210 driver isn't entirely endianness-agnostic as reported by the kernel robot sparse testing. This came to the surface while moving the files around.
The driver is only used on little-endian systems, so this causes no real-world regression, but it is nice to be strict and have some compile coverage also on big endian machines, so fix it up with the right LE accessors.
--- drivers/usb/gadget/udc/fotg210-udc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/fotg210-udc.c +6 -6
@@ -629,10 +629,10 @@ static void fotg210_request_error(struct fotg210_udc *fotg210)static void fotg210_set_address (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) { -if (ctrl->wValue >=0x0100 ) { +if (le16_to_cpu (ctrl->wValue) >=0x0100 ) {fotg210_request_error (fotg210); }else { -fotg210_set_dev_addr (fotg210, ctrl->wValue); +fotg210_set_dev_addr (fotg210,le16_to_cpu (ctrl->wValue));fotg210_set_cxdone (fotg210); } }
@@ -713,17 +713,17 @@ static void fotg210_get_status(struct fotg210_udc *fotg210,switch (ctrl->bRequestType &USB_RECIP_MASK ) {case USB_RECIP_DEVICE : - fotg210->ep0_data =1 <<USB_DEVICE_SELF_POWERED ; + fotg210->ep0_data =cpu_to_le16 (1 <<USB_DEVICE_SELF_POWERED );break ;case USB_RECIP_INTERFACE : - fotg210->ep0_data =0 ; + fotg210->ep0_data =cpu_to_le16 (0 );break ;case USB_RECIP_ENDPOINT : epnum = ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ;if (epnum) fotg210->ep0_data = -fotg210_is_epnstall (fotg210->ep[epnum]) - <<USB_ENDPOINT_HALT ; +cpu_to_le16 (fotg210_is_epnstall (fotg210->ep[epnum]) + <<USB_ENDPOINT_HALT );else fotg210_request_error (fotg210);break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 446/731 staging: vme_user: Fix possible UAF in tsi148_dma_list_add
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 357057ee55d3c99a5de5abe8150f7bca04f8e53b ]
Smatch report warning as follows:
drivers/staging/vme_user/vme_tsi148.c:1757 tsi148_dma_list_add() warn:
'&entry->list' not removed from list
In tsi148_dma_list_add(), the error path "goto err_dma" will not remove entry->list from list->entries, but entry will be freed, then list traversal may cause UAF.
Fix by removeing it from list->entries before free().
--- drivers/vme/bridges/vme_tsi148.c | 1 + 1 file changed, 1 insertion(+)
drivers/vme/bridges/vme_tsi148.c +1 -0
@@ -1765,6 +1765,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,return 0 ; err_dma: +list_del (&entry->list); err_dest: err_source: err_align:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 447/731 usb: typec: Check for ops->exit instead of ops->enter in altmode_exit
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit b6ddd180e3d9f92c1e482b3cdeec7dda086b1341 ]
typec_altmode_exit checks if ops->enter is not NULL but then calls ops->exit a few lines below. Fix that and check for the function pointer it's about to call instead.
--- drivers/usb/typec/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/bus.c +1 -1
@@ -134,7 +134,7 @@ int typec_altmode_exit(struct typec_altmode *adev)if (!adev || !adev->active)return 0 ; -if (!pdev->ops || !pdev->ops->enter) +if (!pdev->ops || !pdev->ops->exit)return -EOPNOTSUPP ;/* Moving to USB Safe State */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 448/731 usb: typec: tcpci: fix of node refcount leak in tcpci_register_port()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 0384e87e3fec735e47f1c133c796f32ef7a72a9b ]
I got the following report while doing device(mt6370-tcpc) load test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/pmic@34/tcpc/connector
The 'fwnode' set in tcpci_parse_config() which is called in tcpci_register_port(), its node refcount is increased in device_get_named_child_node(). It needs be put while exiting, so call fwnode_handle_put() in the error path of tcpci_register_port() and in tcpci_unregister_port() to avoid leak.
--- drivers/usb/typec/tcpm/tcpci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpci.c +4 -1
@@ -817,8 +817,10 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)return ERR_PTR (err); tcpci->port =tcpm_register_port (tcpci->dev, &tcpci->tcpc); -if (IS_ERR (tcpci->port)) +if (IS_ERR (tcpci->port)) { +fwnode_handle_put (tcpci->tcpc.fwnode);return ERR_CAST (tcpci->port); + }return tcpci; }
@@ -827,6 +829,7 @@ EXPORT_SYMBOL_GPL(tcpci_register_port);void tcpci_unregister_port (struct tcpci *tcpci) {tcpm_unregister_port (tcpci->port); +fwnode_handle_put (tcpci->tcpc.fwnode); }EXPORT_SYMBOL_GPL (tcpci_unregister_port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 449/731 usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit 19c220e9ab00f50edefb9667e3101e84a5112df2 ]
We can't just return if devm_tps6598_psy_register fails since previous resources are not devres managed and have yet to be cleaned up.
--- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
@@ -684,7 +684,7 @@ static int tps6598x_probe(struct i2c_client *client) ret =devm_tps6598_psy_register (tps);if (ret) -return ret; + goto err_role_put; tps->port =typec_register_port (&client->dev, &typec_cap);if (IS_ERR (tps->port)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 450/731 usb: typec: tipd: Fix spurious fwnode_handle_put in error path
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit 782c70edc4852a5d39be12377a85501546236212 ]
The err_role_put error path always calls fwnode_handle_put to release the fwnode. This path can be reached after probe itself has already released that fwnode though. Fix that by moving fwnode_handle_put in the happy path to the very end.
--- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
@@ -691,7 +691,6 @@ static int tps6598x_probe(struct i2c_client *client) ret =PTR_ERR (tps->port); goto err_role_put; } -fwnode_handle_put (fwnode);if (status &TPS_STATUS_PLUG_PRESENT ) { ret =tps6598x_connect (tps, status);
@@ -710,6 +709,7 @@ static int tps6598x_probe(struct i2c_client *client) }i2c_set_clientdata (client, tps); +fwnode_handle_put (fwnode);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 451/731 extcon: usbc-tusb320: Add support for mode setting and reset
In reply to Greg Kroah-HartmanFrom: Yassine Oudjana <[email protected]>
[ Upstream commit 70c55d6be634e5f9894169340f3fe5c73f53ac2d ]
Reset the chip and set its mode to default (maintain mode set by PORT pin) during probe to make sure it comes up in the default state.
Stable-dep-of: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
--- drivers/extcon/extcon-usbc-tusb320.c | 85 ++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 4 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +81 -4
@@ -19,15 +19,32 @@#define TUSB320_REG9_ATTACHED_STATE_MASK 0x3#define TUSB320_REG9_CABLE_DIRECTION BIT(5)#define TUSB320_REG9_INTERRUPT_STATUS BIT(4) -#define TUSB320_ATTACHED_STATE_NONE 0x0 -#define TUSB320_ATTACHED_STATE_DFP 0x1 -#define TUSB320_ATTACHED_STATE_UFP 0x2 -#define TUSB320_ATTACHED_STATE_ACC 0x3 + +#define TUSB320_REGA 0xa +#define TUSB320_REGA_I2C_SOFT_RESET BIT(3) +#define TUSB320_REGA_MODE_SELECT_SHIFT 4 +#define TUSB320_REGA_MODE_SELECT_MASK 0x3 + +enum tusb320_attached_state { +TUSB320_ATTACHED_STATE_NONE , +TUSB320_ATTACHED_STATE_DFP , +TUSB320_ATTACHED_STATE_UFP , +TUSB320_ATTACHED_STATE_ACC , +}; + +enum tusb320_mode { +TUSB320_MODE_PORT , +TUSB320_MODE_UFP , +TUSB320_MODE_DFP , +TUSB320_MODE_DRP , +};struct tusb320_priv {struct device *dev;struct regmap *regmap;struct extcon_dev *edev; + +enum tusb320_attached_state state; };static const char *const tusb_attached_states[] = {
@@ -62,6 +79,53 @@ static int tusb320_check_signature(struct tusb320_priv *priv)return 0 ; } +static int tusb320_set_mode (struct tusb320_priv *priv,enum tusb320_mode mode) +{ +int ret; + +/* Mode cannot be changed while cable is attached */ +if (priv->state !=TUSB320_ATTACHED_STATE_NONE ) +return -EBUSY ; + +/* Write mode */ + ret =regmap_write_bits (priv->regmap,TUSB320_REGA , +TUSB320_REGA_MODE_SELECT_MASK <<TUSB320_REGA_MODE_SELECT_SHIFT , + mode <<TUSB320_REGA_MODE_SELECT_SHIFT ); +if (ret) { +dev_err (priv->dev,"failed to write mode: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static int tusb320_reset (struct tusb320_priv *priv) +{ +int ret; + +/* Set mode to default (follow PORT pin) */ + ret =tusb320_set_mode (priv,TUSB320_MODE_PORT ); +if (ret && ret != -EBUSY ) { +dev_err (priv->dev, +"failed to set mode to PORT: %d\n" , ret); +return ret; + } + +/* Perform soft reset */ + ret =regmap_write_bits (priv->regmap,TUSB320_REGA , +TUSB320_REGA_I2C_SOFT_RESET ,1 ); +if (ret) { +dev_err (priv->dev, +"failed to write soft reset bit: %d\n" , ret); +return ret; + } + +/* Wait for chip to go through reset */ +msleep (95 ); + +return 0 ; +} +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) {struct tusb320_priv *priv = dev_id;
@@ -96,6 +160,8 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)extcon_sync (priv->edev,EXTCON_USB );extcon_sync (priv->edev,EXTCON_USB_HOST ); + priv->state = state; +regmap_write (priv->regmap,TUSB320_REG9 , reg);return IRQ_HANDLED ;
@@ -145,6 +211,17 @@ static int tusb320_extcon_probe(struct i2c_client *client,/* update initial state */ tusb320_irq_handler (client->irq, priv); +/* Reset chip to its default state */ + ret =tusb320_reset (priv); +if (ret) +dev_warn (priv->dev,"failed to reset chip: %d\n" , ret); +else +/* +* State and polarity might change after a reset, so update +* them again and make sure the interrupt status bit is cleared. +*/ +tusb320_irq_handler (client->irq, priv); + ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 452/731 extcon: usbc-tusb320: Add support for TUSB320L
In reply to Greg Kroah-HartmanFrom: Yassine Oudjana <[email protected]>
[ Upstream commit ce0320bd3872038569be360870e2d5251b975692 ]
TUSB320L is a newer chip with additional features, and it has additional steps in its mode changing sequence:
- Disable CC state machine,
- Write to mode register,
- Wait for 5 ms,
- Re-enable CC state machine.
It also has an additional register that a revision number can be read from.
Add support for the mode changing sequence, and read the revision number during probe and print it as info.
Stable-dep-of: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
--- drivers/extcon/extcon-usbc-tusb320.c | 82 +++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +79 -3
@@ -21,10 +21,13 @@#define TUSB320_REG9_INTERRUPT_STATUS BIT(4)#define TUSB320_REGA 0xa +#define TUSB320L_REGA_DISABLE_TERM BIT(0)#define TUSB320_REGA_I2C_SOFT_RESET BIT(3)#define TUSB320_REGA_MODE_SELECT_SHIFT 4#define TUSB320_REGA_MODE_SELECT_MASK 0x3 +#define TUSB320L_REGA0_REVISION 0xa0 +enum tusb320_attached_state {TUSB320_ATTACHED_STATE_NONE ,TUSB320_ATTACHED_STATE_DFP ,
@@ -39,11 +42,18 @@ enum tusb320_mode { TUSB320_MODE_DRP, }; +struct tusb320_priv ; + +struct tusb320_ops { +int (*set_mode)(struct tusb320_priv *priv,enum tusb320_mode mode); +int (*get_revision)(struct tusb320_priv *priv,unsigned int *revision); +}; +struct tusb320_priv {struct device *dev;struct regmap *regmap;struct extcon_dev *edev; - +struct tusb320_ops *ops;enum tusb320_attached_state state; };
@@ -99,12 +109,46 @@ static int tusb320_set_mode(struct tusb320_priv *priv, enum tusb320_mode mode)return 0 ; } +static int tusb320l_set_mode (struct tusb320_priv *priv,enum tusb320_mode mode) +{ +int ret; + +/* Disable CC state machine */ + ret =regmap_write_bits (priv->regmap,TUSB320_REGA , +TUSB320L_REGA_DISABLE_TERM ,1 ); +if (ret) { +dev_err (priv->dev, +"failed to disable CC state machine: %d\n" , ret); +return ret; + } + +/* Write mode */ + ret =regmap_write_bits (priv->regmap,TUSB320_REGA , +TUSB320_REGA_MODE_SELECT_MASK <<TUSB320_REGA_MODE_SELECT_SHIFT , + mode <<TUSB320_REGA_MODE_SELECT_SHIFT ); +if (ret) { +dev_err (priv->dev,"failed to write mode: %d\n" , ret); + goto err; + } + +msleep (5 ); +err: +/* Re-enable CC state machine */ + ret =regmap_write_bits (priv->regmap,TUSB320_REGA , +TUSB320L_REGA_DISABLE_TERM ,0 ); +if (ret) +dev_err (priv->dev, +"failed to re-enable CC state machine: %d\n" , ret); + +return ret; +} +static int tusb320_reset (struct tusb320_priv *priv) {int ret;/* Set mode to default (follow PORT pin) */ - ret =tusb320_set_mode (priv,TUSB320_MODE_PORT ); + ret = priv->ops->set_mode (priv,TUSB320_MODE_PORT );if (ret && ret != -EBUSY ) {dev_err (priv->dev,"failed to set mode to PORT: %d\n" , ret);
@@ -126,6 +170,20 @@ static int tusb320_reset(struct tusb320_priv *priv)return 0 ; } +static int tusb320l_get_revision (struct tusb320_priv *priv,unsigned int *revision) +{ +return regmap_read (priv->regmap,TUSB320L_REGA0_REVISION , revision); +} + +static struct tusb320_ops tusb320_ops = { + .set_mode = tusb320_set_mode, +}; + +static struct tusb320_ops tusb320l_ops = { + .set_mode = tusb320l_set_mode, + .get_revision = tusb320l_get_revision, +}; +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) {struct tusb320_priv *priv = dev_id;
@@ -176,6 +234,8 @@ static int tusb320_extcon_probe(struct i2c_client *client, const struct i2c_device_id *id) {struct tusb320_priv *priv; +const void *match_data; +unsigned int revision;int ret; priv =devm_kzalloc (&client->dev,sizeof (*priv),GFP_KERNEL );
@@ -191,12 +251,27 @@ static int tusb320_extcon_probe(struct i2c_client *client,if (ret)return ret; + match_data =device_get_match_data (&client->dev); +if (!match_data) +return -EINVAL ; + + priv->ops = (struct tusb320_ops *)match_data; + priv->edev =devm_extcon_dev_allocate (priv->dev, tusb320_extcon_cable);if (IS_ERR (priv->edev)) {dev_err (priv->dev,"failed to allocate extcon device\n" );return PTR_ERR (priv->edev); } +if (priv->ops->get_revision) { + ret = priv->ops->get_revision (priv, &revision); +if (ret) +dev_warn (priv->dev, +"failed to read revision register: %d\n" , ret); +else +dev_info (priv->dev,"chip revision %d\n" , revision); + } + ret =devm_extcon_dev_register (priv->dev, priv->edev);if (ret <0 ) {dev_err (priv->dev,"failed to register extcon device\n" );
@@ -231,7 +306,8 @@ static int tusb320_extcon_probe(struct i2c_client *client, }static const struct of_device_id tusb320_extcon_dt_match[] = { - { .compatible ="ti,tusb320" , }, + { .compatible ="ti,tusb320" , .data = &tusb320_ops, }, + { .compatible ="ti,tusb320l" , .data = &tusb320l_ops, }, { } };MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 453/731 usb: typec: Factor out non-PD fwnode properties
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
[ Upstream commit 2e7dfb0e9cacad0f1adbc4b97f0b96ba35027f24 ]
Basic programmable non-PD Type-C port controllers do not need the full TCPM library, but they share the same devicetree binding and the same typec_capability structure. Factor out a helper for parsing those properties which map to fields in struct typec_capability, so the code can be shared between TCPM and basic non-TCPM drivers.
Stable-dep-of: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
--- drivers/usb/typec/class.c | 43 +++++++++++++++++++++++++++++++++++ drivers/usb/typec/tcpm/tcpm.c | 24 +------------------ include/linux/usb/typec.h | 3 +++ 3 files changed, 47 insertions(+), 23 deletions(-)
drivers/usb/typec/class.c +43 -0
@@ -1895,6 +1895,49 @@ void *typec_get_drvdata(struct typec_port *port) }EXPORT_SYMBOL_GPL (typec_get_drvdata); +int typec_get_fw_cap (struct typec_capability *cap, +struct fwnode_handle *fwnode) +{ +const char *cap_str; +int ret; + + cap->fwnode = fwnode; + + ret =fwnode_property_read_string (fwnode,"power-role" , &cap_str); +if (ret <0 ) +return ret; + + ret =typec_find_port_power_role (cap_str); +if (ret <0 ) +return ret; + cap->type = ret; + +/* USB data support is optional */ + ret =fwnode_property_read_string (fwnode,"data-role" , &cap_str); +if (ret ==0 ) { + ret =typec_find_port_data_role (cap_str); +if (ret <0 ) +return ret; + cap->data = ret; + } + +/* Get the preferred power role for a DRP */ +if (cap->type ==TYPEC_PORT_DRP ) { + cap->prefer_role =TYPEC_NO_PREFERRED_ROLE ; + + ret =fwnode_property_read_string (fwnode,"try-power-role" , &cap_str); +if (ret ==0 ) { + ret =typec_find_power_role (cap_str); +if (ret <0 ) +return ret; + cap->prefer_role = ret; + } + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (typec_get_fw_cap); +/** * typec_port_register_altmode - Register USB Type-C Port Alternate Mode * @port: USB Type-C Port that supports the alternate mode
drivers/usb/typec/tcpm/tcpm.c +1 -23
@@ -5928,7 +5928,6 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode) {const char *opmode_str; -const char *cap_str;int ret;u32 mw, frs_current;
@@ -5944,23 +5943,10 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,*/ fw_devlink_purge_absent_suppliers (fwnode); -/* USB data support is optional */ - ret =fwnode_property_read_string (fwnode,"data-role" , &cap_str); -if (ret ==0 ) { - ret =typec_find_port_data_role (cap_str); -if (ret <0 ) -return ret; - port->typec_caps.data = ret; - } - - ret =fwnode_property_read_string (fwnode,"power-role" , &cap_str); + ret =typec_get_fw_cap (&port->typec_caps, fwnode);if (ret <0 )return ret; - ret =typec_find_port_power_role (cap_str); -if (ret <0 ) -return ret; - port->typec_caps.type = ret; port->port_type = port->typec_caps.type; port->pd_supported = !fwnode_property_read_bool (fwnode,"pd-disable" );
@@ -5997,14 +5983,6 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,if (port->port_type ==TYPEC_PORT_SRC )return 0 ; -/* Get the preferred power role for DRP */ - ret =fwnode_property_read_string (fwnode,"try-power-role" , &cap_str); -if (ret <0 ) -return ret; - - port->typec_caps.prefer_role =typec_find_power_role (cap_str); -if (port->typec_caps.prefer_role <0 ) -return -EINVAL ; sink: port->self_powered =fwnode_property_read_bool (fwnode,"self-powered" );
include/linux/usb/typec.h +3 -0
@@ -295,6 +295,9 @@ int typec_set_mode(struct typec_port *port, int mode);void *typec_get_drvdata (struct typec_port *port); +int typec_get_fw_cap (struct typec_capability *cap, +struct fwnode_handle *fwnode); +int typec_find_pwr_opmode (const char *name);int typec_find_orientation (const char *name);int typec_find_port_power_role (const char *name);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 454/731 extcon: usbc-tusb320: Factor out extcon into dedicated functions
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 9483811a126a319ecac749f1b767ea5faecc7aed ]
Move extcon code into separate functions in preparation for addition of USB TYPE-C support. No functional change.
Stable-dep-of: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
--- drivers/extcon/extcon-usbc-tusb320.c | 75 +++++++++++++++++----------- 1 file changed, 46 insertions(+), 29 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +46 -29
@@ -184,19 +184,9 @@ static struct tusb320_ops tusb320l_ops = { .get_revision = tusb320l_get_revision, }; -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static void tusb320_extcon_irq_handler (struct tusb320_priv *priv,u8 reg) { -struct tusb320_priv *priv = dev_id;int state, polarity; -unsigned reg; - -if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) { -dev_err (priv->dev,"error during i2c read!\n" ); -return IRQ_NONE ; - } - -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) -return IRQ_NONE ; state = (reg >>TUSB320_REG9_ATTACHED_STATE_SHIFT ) &TUSB320_REG9_ATTACHED_STATE_MASK ;
@@ -219,6 +209,22 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)extcon_sync (priv->edev,EXTCON_USB_HOST ); priv->state = state; +} + +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; +unsigned int reg; + +if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) { +dev_err (priv->dev,"error during i2c read!\n" ); +return IRQ_NONE ; + } + +if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +return IRQ_NONE ; + +tusb320_extcon_irq_handler (priv, reg);regmap_write (priv->regmap,TUSB320_REG9 , reg);
@@ -230,8 +236,32 @@ static const struct regmap_config tusb320_regmap_config = { .val_bits = 8, }; -static int tusb320_extcon_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int tusb320_extcon_probe (struct tusb320_priv *priv) +{ +int ret; + + priv->edev =devm_extcon_dev_allocate (priv->dev, tusb320_extcon_cable); +if (IS_ERR (priv->edev)) { +dev_err (priv->dev,"failed to allocate extcon device\n" ); +return PTR_ERR (priv->edev); + } + + ret =devm_extcon_dev_register (priv->dev, priv->edev); +if (ret <0 ) { +dev_err (priv->dev,"failed to register extcon device\n" ); +return ret; + } + +extcon_set_property_capability (priv->edev,EXTCON_USB , +EXTCON_PROP_USB_TYPEC_POLARITY ); +extcon_set_property_capability (priv->edev,EXTCON_USB_HOST , +EXTCON_PROP_USB_TYPEC_POLARITY ); + +return 0 ; +} + +static int tusb320_probe (struct i2c_client *client, +const struct i2c_device_id *id) {struct tusb320_priv *priv;const void *match_data;
@@ -257,12 +287,6 @@ static int tusb320_extcon_probe(struct i2c_client *client, priv->ops = (struct tusb320_ops *)match_data; - priv->edev =devm_extcon_dev_allocate (priv->dev, tusb320_extcon_cable); -if (IS_ERR (priv->edev)) { -dev_err (priv->dev,"failed to allocate extcon device\n" ); -return PTR_ERR (priv->edev); - } -if (priv->ops->get_revision) { ret = priv->ops->get_revision (priv, &revision);if (ret)
@@ -272,16 +296,9 @@ static int tusb320_extcon_probe(struct i2c_client *client,dev_info (priv->dev,"chip revision %d\n" , revision); } - ret =devm_extcon_dev_register (priv->dev, priv->edev); -if (ret <0 ) { -dev_err (priv->dev,"failed to register extcon device\n" ); + ret =tusb320_extcon_probe (priv); +if (ret)return ret; - } - -extcon_set_property_capability (priv->edev,EXTCON_USB , -EXTCON_PROP_USB_TYPEC_POLARITY ); -extcon_set_property_capability (priv->edev,EXTCON_USB_HOST , -EXTCON_PROP_USB_TYPEC_POLARITY );/* update initial state */ tusb320_irq_handler (client->irq, priv);
@@ -313,7 +330,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { - .probe = tusb320_extcon_probe, + .probe = tusb320_probe, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 455/731 extcon: usbc-tusb320: Add USB TYPE-C support
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit bf7571c00dca0a9c5af3f5125ef5a89a40b13cd5 ]
The TI TUSB320 seems like a better fit for USB TYPE-C subsystem, which can expose details collected by the TUSB320 in a far more precise way than extcon. Since there are existing users in the kernel and in DT which depend on the extcon interface, keep it for now.
Add TYPE-C interface and expose the supported supply current, direction and connector polarity via the TYPE-C interface.
Stable-dep-of: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
--- drivers/extcon/Kconfig | 2 +- drivers/extcon/extcon-usbc-tusb320.c | 159 +++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-)
drivers/extcon/Kconfig +1 -1
@@ -180,7 +180,7 @@ config EXTCON_USBC_CROS_EC config EXTCON_USBC_TUSB320 tristate "TI TUSB320 USB-C extcon support" - depends on I2C + depends on I2C && TYPEC select REGMAP_I2C help Say Y here to enable support for USB Type C cable detection extcon
drivers/extcon/extcon-usbc-tusb320.c +159 -0
207 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 456/731 extcon: usbc-tusb320: Update state on probe even if no IRQ pending
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 581c848b610dbf3fe1ed4d85fd53d0743c61faba ]
Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning tusb320_irq_handler() into a thin wrapper around tusb320_state_update_handler(), where the later now contains the bulk of the code of tusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handler tusb320_irq_handler() callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.
--- drivers/extcon/extcon-usbc-tusb320.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +12 -5
@@ -313,9 +313,9 @@ static void tusb320_typec_irq_handler(struct tusb320_priv *priv, u8 reg9)typec_set_pwr_opmode (port,TYPEC_PWR_MODE_USB ); } -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static irqreturn_t tusb320_state_update_handler (struct tusb320_priv *priv, +bool force_update) { -struct tusb320_priv *priv = dev_id;unsigned int reg;if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) {
@@ -323,7 +323,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +if (!force_update && !(reg &TUSB320_REG9_INTERRUPT_STATUS ))return IRQ_NONE ;tusb320_extcon_irq_handler (priv, reg);
@@ -334,6 +334,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; + +return tusb320_state_update_handler (priv, false); +} +static const struct regmap_config tusb320_regmap_config = { .reg_bits =8 , .val_bits =8 ,
@@ -460,7 +467,7 @@ static int tusb320_probe(struct i2c_client *client,return ret;/* update initial state */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true);/* Reset chip to its default state */ ret =tusb320_reset (priv);
@@ -471,7 +478,7 @@ static int tusb320_probe(struct i2c_client *client,* State and polarity might change after a reset, so update * them again and make sure the interrupt status bit is cleared. */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true); ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler,
Signature · 1 line
2.35.1
Re: [PATCH 5.15 456/731] extcon: usbc-tusb320: Update state on probe even if no IRQ pending
Quoted 25 lines · Greg Kroah-Hartman
From: Marek Vasut <[email protected]>
[ Upstream commit
581c848b610dbf3fe1ed4d85fd53d0743c61faba]Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning
tusb320_irq_handler()into a thin wrapper aroundtusb320_state_update_handler(), where the later now contains the bulk of the code oftusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handlertusb320_irq_handler()callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.
Quoted 8 lines
Fixes 06bc4ca115cdd ("extcon: Add driver for TI TUSB320")Signed-off-by Marek Vasut <[email protected]>Reviewed-by Alvin Šipraga <[email protected]>Acked-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Is the Fixes: tag here actually wrong? There was a regression report here:
https://lore.kernel.org/all/[email protected]/
which this patch fixed. But according to the report, it was a regression introduced by Marek's recent addition of typec support. Since that new functionality is not normally wanted in stable, can these three tusb320 patches simply be dropped?
Marek, Peter, any thoughts?
Kind regards,
Alvin
Quoted 65 lines
drivers/extcon/extcon-usbc-tusb320.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)drivers/extcon/extcon-usbc-tusb320.c +12
-5@@ -313,9 +313,9 @@ static void tusb320_typec_irq_handler(struct tusb320_priv *priv, u8 reg9)typec_set_pwr_opmode (port,TYPEC_PWR_MODE_USB ); } -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static irqreturn_t tusb320_state_update_handler (struct tusb320_priv *priv, +bool force_update) { -struct tusb320_priv *priv = dev_id;unsigned int reg;if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) {@@ -323,7 +323,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +if (!force_update && !(reg &TUSB320_REG9_INTERRUPT_STATUS ))return IRQ_NONE ;tusb320_extcon_irq_handler (priv, reg);@@ -334,6 +334,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; + +return tusb320_state_update_handler (priv, false); +} +static const struct regmap_config tusb320_regmap_config = { .reg_bits =8 , .val_bits =8 ,@@ -460,7 +467,7 @@ static int tusb320_probe(struct i2c_client *client,return ret;/* update initial state */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true);/* Reset chip to its default state */ ret =tusb320_reset (priv);@@ -471,7 +478,7 @@ static int tusb320_probe(struct i2c_client *client,* State and polarity might change after a reset, so update * them again and make sure the interrupt status bit is cleared. */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true); ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler,Signature · 1 line
2.35.1
Re: [PATCH 5.15 456/731] extcon: usbc-tusb320: Update state on probe even if no IRQ pending
Hi!
Quoted 35 lines · Alvin Šipraga
Quoted 25 lines · Greg Kroah-Hartman
From: Marek Vasut <[email protected]>
[ Upstream commit
581c848b610dbf3fe1ed4d85fd53d0743c61faba]Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning
tusb320_irq_handler()into a thin wrapper aroundtusb320_state_update_handler(), where the later now contains the bulk of the code oftusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handlertusb320_irq_handler()callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.Quoted 8 lines
Fixes 06bc4ca115cdd ("extcon: Add driver for TI TUSB320")Signed-off-by Marek Vasut <[email protected]>Reviewed-by Alvin Šipraga <[email protected]>Acked-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 6 lines
Is the Fixes: tag here actually wrong? There was a regression report here:
https://lore.kernel.org/all/[email protected]/
which this patch fixed. But according to the report, it was a regression introduced by Marek's recent addition of typec support. Since that new
The fixes tag is correct here. What is wrong is that this patch does not fix
the above reported regression which was instead fixed by341fd15e2e18 ("extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered")
However, this patch still fixes a problem so it should be considered for stable.
From only looking at this patch, it looks easy to backport to kernels that do not havebf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
and its followup fix.
But I have of course not tried, so maybe I'm wrong...
Cheers,
Peter
Quoted 73 lines
functionality is not normally wanted in stable, can these three tusb320 patches simply be dropped?
Marek, Peter, any thoughts?
Kind regards,
AlvinQuoted 65 lines
drivers/extcon/extcon-usbc-tusb320.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)drivers/extcon/extcon-usbc-tusb320.c +12
-5@@ -313,9 +313,9 @@ static void tusb320_typec_irq_handler(struct tusb320_priv *priv, u8 reg9)typec_set_pwr_opmode (port,TYPEC_PWR_MODE_USB ); } -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static irqreturn_t tusb320_state_update_handler (struct tusb320_priv *priv, +bool force_update) { -struct tusb320_priv *priv = dev_id;unsigned int reg;if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) {@@ -323,7 +323,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +if (!force_update && !(reg &TUSB320_REG9_INTERRUPT_STATUS ))return IRQ_NONE ;tusb320_extcon_irq_handler (priv, reg);@@ -334,6 +334,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; + +return tusb320_state_update_handler (priv, false); +} +static const struct regmap_config tusb320_regmap_config = { .reg_bits =8 , .val_bits =8 ,@@ -460,7 +467,7 @@ static int tusb320_probe(struct i2c_client *client,return ret;/* update initial state */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true);/* Reset chip to its default state */ ret =tusb320_reset (priv);@@ -471,7 +478,7 @@ static int tusb320_probe(struct i2c_client *client,* State and polarity might change after a reset, so update * them again and make sure the interrupt status bit is cleared. */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true); ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler,Signature · 1 line
2.35.1
Re: [PATCH 5.15 456/731] extcon: usbc-tusb320: Update state on probe even if no IRQ pending
Quoted 49 lines · Peter Rosin
Hi!
Quoted 35 lines · Alvin Šipraga
Quoted 25 lines · Greg Kroah-Hartman
From: Marek Vasut <[email protected]>
[ Upstream commit
581c848b610dbf3fe1ed4d85fd53d0743c61faba]Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning
tusb320_irq_handler()into a thin wrapper aroundtusb320_state_update_handler(), where the later now contains the bulk of the code oftusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handlertusb320_irq_handler()callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.Quoted 8 lines
Fixes 06bc4ca115cdd ("extcon: Add driver for TI TUSB320")Signed-off-by Marek Vasut <[email protected]>Reviewed-by Alvin Šipraga <[email protected]>Acked-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 6 lines
Is the Fixes: tag here actually wrong? There was a regression report here:
https://lore.kernel.org/all/[email protected]/
which this patch fixed. But according to the report, it was a regression introduced by Marek's recent addition of typec support. Since that new
The fixes tag is correct here. What is wrong is that this patch does not fix
the above reported regression which was instead fixed by341fd15e2e18("extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered")
Quoted 8 lines
However, this patch still fixes a problem so it should be considered for stable.
From only looking at this patch, it looks easy to backport to kernels that do not have
bf7571c00dca("extcon: usbc-tusb320: Add USB TYPE-C support")
and its followup fix.But I have of course not tried, so maybe I'm wrong...
Sorry for the reply to self, but here's a backport for v5.15
Cheers,
Peter
drivers/extcon/extcon-usbc-tusb320.c +11 -4
@@ -62,9 +62,9 @@ static int tusb320_check_signature(struct tusb320_priv *priv)return 0 ; } -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static irqreturn_t tusb320_state_update_handler (struct tusb320_priv *priv, +bool force_update) { -struct tusb320_priv *priv = dev_id;int state, polarity;unsigned reg;
@@ -73,7 +73,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +if (!force_update && !(reg &TUSB320_REG9_INTERRUPT_STATUS ))return IRQ_NONE ; state = (reg >> TUSB320_REG9_ATTACHED_STATE_SHIFT) &
@@ -101,6 +101,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; + +return tusb320_state_update_handler (priv, false); +} +static const struct regmap_config tusb320_regmap_config = { .reg_bits =8 , .val_bits =8 ,
@@ -143,7 +150,7 @@ static int tusb320_extcon_probe(struct i2c_client *client, EXTCON_PROP_USB_TYPEC_POLARITY);/* update initial state */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true); ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler,
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 456/731] extcon: usbc-tusb320: Update state on probe even if no IRQ pending
Quoted 57 lines · Peter Rosin
Quoted 56 lines · Peter Rosin
Hi!
Quoted 35 lines · Alvin Šipraga
Quoted 25 lines · Greg Kroah-Hartman
From: Marek Vasut <[email protected]>
[ Upstream commit
581c848b610dbf3fe1ed4d85fd53d0743c61faba]Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning
tusb320_irq_handler()into a thin wrapper aroundtusb320_state_update_handler(), where the later now contains the bulk of the code oftusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handlertusb320_irq_handler()callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.Quoted 8 lines
Fixes 06bc4ca115cdd ("extcon: Add driver for TI TUSB320")Signed-off-by Marek Vasut <[email protected]>Reviewed-by Alvin Šipraga <[email protected]>Acked-by Heikki Krogerus <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 6 lines
Is the Fixes: tag here actually wrong? There was a regression report here:
https://lore.kernel.org/all/[email protected]/
which this patch fixed. But according to the report, it was a regression introduced by Marek's recent addition of typec support. Since that new
The fixes tag is correct here. What is wrong is that this patch does not fix
the above reported regression which was instead fixed by341fd15e2e18("extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered")However, this patch still fixes a problem so it should be considered for stable.
From only looking at this patch, it looks easy to backport to kernels that do not have
bf7571c00dca("extcon: usbc-tusb320: Add USB TYPE-C support")
and its followup fix.
Quoted 5 lines
Quoted 1 line
But I have of course not tried, so maybe I'm wrong...
Sorry for the reply to self, but here's a backport for v5.15
Signed-off-by Peter Rosin <[email protected]>
Can you send this as a new thread with the proper header and subject line so that we can apply it correctly?
Right now it's burried down in this thread...
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 457/731 serial: amba-pl011: avoid SBSA UART accessing DMACR register
In reply to Greg Kroah-HartmanFrom: Jiamei Xie <[email protected]>
[ Upstream commit 94cdb9f33698478b0e7062586633c42c6158a786 ]
Chapter "B Generic UART" in "ARM Server Base System Architecture" [1] documentation describes a generic UART interface. Such generic UART does not support DMA. In current code, sbsa_uart_pops and amba_pl011_pops share the same stop_rx operation, which will invoke pl011_dma_rx_stop, leading to an access of the DMACR register. This commit adds a using_rx_dma check in pl011_dma_rx_stop to avoid the access to DMACR register for SBSA UARTs which does not support DMA.
When the kernel enables DMA engine with "CONFIG_DMA_ENGINE=y", Linux
SBSA PL011 driver will access PL011 DMACR register in some functions.
For most real SBSA Pl011 hardware implementations, the DMACR write
behaviour will be ignored. So these DMACR operations will not cause
obvious problems. But for some virtual SBSA PL011 hardware, like Xen
virtual SBSA PL011 (vpl011) device, the behaviour might be different.
Xen vpl011 emulation will inject a data abort to guest, when guest is
accessing an unimplemented UART register. As Xen VPL011 is SBSA
compatible, it will not implement DMACR register. So when Linux SBSA
PL011 driver access DMACR register, it will get an unhandled data abort
fault and the application will get a segmentation fault:
Unhandled fault at 0xffffffc00944d048
Mem abort info:
ESR = 0x96000000
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x00: ttbr address size fault
Data abort info:
ISV = 0, ISS = 0x00000000
CM = 0, WnR = 0
swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000020e2e000
[ffffffc00944d048] pgd=100000003ffff803, p4d=100000003ffff803, pud=100000003ffff803, pmd=100000003fffa803, pte=006800009c090f13
Internal error: ttbr address size fault: 96000000 [#1] PREEMPT SMP ... Call trace: pl011_stop_rx+0x70/0x80 tty_port_shutdown+0x7c/0xb4 tty_port_close+0x60/0xcc uart_close+0x34/0x8c tty_release+0x144/0x4c0 __fput+0x78/0x220 ____fput+0x1c/0x30 task_work_run+0x88/0xc0 do_notify_resume+0x8d0/0x123c el0_svc+0xa8/0xc0 el0t_64_sync_handler+0xa4/0x130 el0t_64_sync+0x1a0/0x1a4 Code: b9000083 b901f001 794038a0 8b000042 (b9000041) ---[ end trace 83dd93df15c3216f ]---
note: bootlogd[132] exited with preempt_count 1 /etc/rcS.d/S07bootlogd: line 47: 132 Segmentation fault start-stop-daemon
This has been discussed in the Xen community, and we think it should fix this in Linux. See [2] for more information.
[1] https://developer.arm.com/documentation/den0094/c/?lang=en
[2] https://lists.xenproject.org/archives/html/xen-devel/2022-11/msg00543.html
--- drivers/tty/serial/amba-pl011.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/amba-pl011.c +3 -0
@@ -1050,6 +1050,9 @@ static void pl011_dma_rx_callback(void *data)*/ static inline void pl011_dma_rx_stop (struct uart_amba_port *uap) { +if (!uap->using_rx_dma) +return ; +/* FIXME. Just disable the DMA enable */ uap->dmacr &= ~UART011_RXDMAE ;pl011_write (uap->dmacr, uap,REG_DMACR );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 458/731 serial: pl011: Do not clear RX FIFO & RX interrupt in unthrottle.
In reply to Greg Kroah-HartmanFrom: delisun <[email protected]>
[ Upstream commit 032d5a71ed378ffc6a2d41a187d8488a4f9fe415 ]
Clearing the RX FIFO will cause data loss.
Copy the pl011_enabl_interrupts implementation, and remove the clear interrupt and FIFO part of the code.
--- drivers/tty/serial/amba-pl011.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/tty/serial/amba-pl011.c +10 -1
@@ -1836,8 +1836,17 @@ static void pl011_enable_interrupts(struct uart_amba_port *uap)static void pl011_unthrottle_rx (struct uart_port *port) { struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); +unsigned long flags; -pl011_enable_interrupts (uap); +spin_lock_irqsave (&uap->port.lock, flags); + + uap->im =UART011_RTIM ; +if (!pl011_dma_rx_running (uap)) + uap->im |=UART011_RXIM ; + +pl011_write (uap->im, uap,REG_IMSC ); + +spin_unlock_irqrestore (&uap->port.lock, flags); }static int pl011_startup (struct uart_port *port)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 459/731 serial: stm32: move dma_request_chan() before clk_prepare_enable()
In reply to Greg Kroah-HartmanFrom: Valentin Caron <[email protected]>
[ Upstream commit 0d114e9ff940ebad8e88267013bf96c605a6b336 ]
If dma_request_chan() returns a PROBE_DEFER error, clk_disable_unprepare() will be called and USART clock will be disabled. But early console can be still active on the same USART.
While moving dma_request_chan() before clk_prepare_enable(), the clock won't be taken in case of a DMA PROBE_DEFER error, and so it doesn't need to be disabled. Then USART is still clocked for early console.
--- drivers/tty/serial/stm32-usart.c | 47 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-)
drivers/tty/serial/stm32-usart.c +23 -24
@@ -1363,22 +1363,10 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)if (!stm32port->info)return -EINVAL ; - ret =stm32_usart_init_port (stm32port, pdev); -if (ret) -return ret; - -if (stm32port->wakeup_src) { -device_set_wakeup_capable (&pdev->dev, true); - ret =dev_pm_set_wake_irq (&pdev->dev, stm32port->port.irq); -if (ret) - goto err_deinit_port; - } - stm32port->rx_ch =dma_request_chan (&pdev->dev,"rx" ); -if (PTR_ERR (stm32port->rx_ch) == -EPROBE_DEFER ) { - ret = -EPROBE_DEFER ; - goto err_wakeirq; - } +if (PTR_ERR (stm32port->rx_ch) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +/* Fall back in interrupt mode for any non-deferral error */ if (IS_ERR (stm32port->rx_ch)) stm32port->rx_ch =NULL ;
@@ -1392,6 +1380,17 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)if (IS_ERR (stm32port->tx_ch)) stm32port->tx_ch =NULL ; + ret =stm32_usart_init_port (stm32port, pdev); +if (ret) + goto err_dma_tx; + +if (stm32port->wakeup_src) { +device_set_wakeup_capable (&pdev->dev, true); + ret =dev_pm_set_wake_irq (&pdev->dev, stm32port->port.irq); +if (ret) + goto err_deinit_port; + } +if (stm32port->rx_ch &&stm32_usart_of_dma_rx_probe (stm32port, pdev)) {/* Fall back in interrupt mode */ dma_release_channel (stm32port->rx_ch);
@@ -1428,19 +1427,11 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)pm_runtime_set_suspended (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); -if (stm32port->tx_ch) { +if (stm32port->tx_ch)stm32_usart_of_dma_tx_remove (stm32port, pdev); -dma_release_channel (stm32port->tx_ch); - } -if (stm32port->rx_ch)stm32_usart_of_dma_rx_remove (stm32port, pdev); -err_dma_rx: -if (stm32port->rx_ch) -dma_release_channel (stm32port->rx_ch); - -err_wakeirq:if (stm32port->wakeup_src)dev_pm_clear_wake_irq (&pdev->dev);
@@ -1450,6 +1441,14 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)stm32_usart_deinit_port (stm32port); +err_dma_tx: +if (stm32port->tx_ch) +dma_release_channel (stm32port->tx_ch); + +err_dma_rx: +if (stm32port->rx_ch) +dma_release_channel (stm32port->rx_ch); +return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 460/731 serial: pch: Fix PCI device refcount leak in pch_request_dma()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 8be3a7bf773700534a6e8f87f6ed2ed111254be5 ]
As comment of pci_get_slot() says, it returns a pci_device with its refcount increased. The caller must decrement the reference count by calling pci_dev_put().
Since 'dma_dev' is only used to filter the channel in filter(), we can call pci_dev_put() before exiting from pch_request_dma(). Add the missing pci_dev_put() for the normal and error path.
--- drivers/tty/serial/pch_uart.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/pch_uart.c +4 -0
@@ -707,6 +707,7 @@ static void pch_request_dma(struct uart_port *port)if (!chan) {dev_err (priv->port.dev,"%s:dma_request_channel FAILS(Tx)\n" , __func__); +pci_dev_put (dma_dev);return ; } priv->chan_tx = chan;
@@ -723,6 +724,7 @@ static void pch_request_dma(struct uart_port *port) __func__);dma_release_channel (priv->chan_tx); priv->chan_tx =NULL ; +pci_dev_put (dma_dev);return ; }
@@ -730,6 +732,8 @@ static void pch_request_dma(struct uart_port *port) priv->rx_buf_virt =dma_alloc_coherent (port->dev, port->fifosize, &priv->rx_buf_dma,GFP_KERNEL ); priv->chan_rx = chan; + +pci_dev_put (dma_dev); }static void pch_dma_rx_complete (void *arg)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 461/731 tty: serial: clean up stop-tx part in altera_uart_tx_chars()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit d9c128117da41cf4cb0e80ae565b5d3ac79dffac ]
The "stop TX" path in altera_uart_tx_chars() is open-coded, so:
* use uart_circ_empty() to check if the buffer is empty, and
* when true, call altera_uart_stop_tx().
Stable-dep-of: 1307c5d33cce ("serial: altera_uart: fix locking in polling mode")
--- drivers/tty/serial/altera_uart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/altera_uart.c +2 -4
@@ -272,10 +272,8 @@ static void altera_uart_tx_chars(struct altera_uart *pp)if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); -if (xmit->head == xmit->tail) { - pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK ; -altera_uart_update_ctrl_reg (pp); - } +if (uart_circ_empty (xmit)) +altera_uart_stop_tx (port); }static irqreturn_t altera_uart_interrupt (int irq,void *data)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 462/731 tty: serial: altera_uart_{r,t}x_chars() need only uart_port
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit 3af44d9bb0539d5fa27d6159d696fda5f3747bff ]
Both altera_uart_{r,t}x_chars() need only uart_port, not altera_uart. So pass the former from altera_uart_interrupt() directly.
Apart it maybe saves a dereference, this makes the transition of altera_uart_tx_chars() easier to follow in the next patch.
Stable-dep-of: 1307c5d33cce ("serial: altera_uart: fix locking in polling mode")
--- drivers/tty/serial/altera_uart.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/tty/serial/altera_uart.c +4 -6
@@ -199,9 +199,8 @@ static void altera_uart_set_termios(struct uart_port *port,*/ } -static void altera_uart_rx_chars (struct altera_uart *pp) +static void altera_uart_rx_chars (struct uart_port *port) { -struct uart_port *port = &pp->port;unsigned char ch, flag;unsigned short status;
@@ -246,9 +245,8 @@ static void altera_uart_rx_chars(struct altera_uart *pp)tty_flip_buffer_push (&port->state->port); } -static void altera_uart_tx_chars (struct altera_uart *pp) +static void altera_uart_tx_chars (struct uart_port *port) { -struct uart_port *port = &pp->port;struct circ_buf *xmit = &port->state->xmit;if (port->x_char) {
@@ -286,9 +284,9 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data)spin_lock (&port->lock);if (isr &ALTERA_UART_STATUS_RRDY_MSK ) -altera_uart_rx_chars (pp); +altera_uart_rx_chars (port);if (isr &ALTERA_UART_STATUS_TRDY_MSK ) -altera_uart_tx_chars (pp); +altera_uart_tx_chars (port);spin_unlock (&port->lock);return IRQ_RETVAL (isr);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 463/731 serial: altera_uart: fix locking in polling mode
In reply to Greg Kroah-HartmanFrom: Gabriel Somlo <[email protected]>
[ Upstream commit 1307c5d33cce8a41dd77c2571e4df65a5b627feb ]
Since altera_uart_interrupt() may also be called from a poll timer in "serving_softirq" context, use spin_[lock_irqsave|unlock_irqrestore] variants, which are appropriate for both softirq and hardware interrupt contexts.
--- drivers/tty/serial/altera_uart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/altera_uart.c +3 -2
@@ -278,16 +278,17 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data) {struct uart_port *port = data; struct altera_uart *pp = container_of(port, struct altera_uart, port); +unsigned long flags;unsigned int isr; isr =altera_uart_readl (port,ALTERA_UART_STATUS_REG ) & pp->imr; -spin_lock (&port->lock); +spin_lock_irqsave (&port->lock, flags);if (isr &ALTERA_UART_STATUS_RRDY_MSK )altera_uart_rx_chars (port);if (isr &ALTERA_UART_STATUS_TRDY_MSK )altera_uart_tx_chars (port); -spin_unlock (&port->lock); +spin_unlock_irqrestore (&port->lock, flags);return IRQ_RETVAL (isr); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 464/731 serial: sunsab: Fix error handling in sunsab_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 1a6ec673fb627c26e2267ca0a03849f91dbd9b40 ]
The sunsab_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the allocated sunsab_ports is leaked.
Fix by free sunsab_ports and set it to NULL when platform_driver_register() failed.
--- drivers/tty/serial/sunsab.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/sunsab.c +7 -1
@@ -1137,7 +1137,13 @@ static int __init sunsab_init(void) } } -return platform_driver_register (&sab_driver); + err =platform_driver_register (&sab_driver); +if (err) { +kfree (sunsab_ports); + sunsab_ports =NULL ; + } + +return err; } static void __exit sunsab_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 465/731 test_firmware: fix memory leak in test_firmware_init()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 7610615e8cdb3f6f5bbd9d8e7a5d8a63e3cabf2e ]
When misc_register() failed in test_firmware_init(), the memory pointed by test_fw_config->name is not released. The memory leak information is as follows:
unreferenced object 0xffff88810a34cb00 (size 32):
comm "insmod", pid 7952, jiffies 4294948236 (age 49.060s) hex dump (first 32 bytes):
74 65 73 74 2d 66 69 72 6d 77 61 72 65 2e 62 69 test-firmware.bi
6e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 n...............
backtrace:
[<ffffffff81b21fcb>] __kmalloc_node_track_caller+0x4b/0xc0
[<ffffffff81affb96>] kstrndup+0x46/0xc0
[<ffffffffa0403a49>] __test_firmware_config_init+0x29/0x380 [test_firmware]
[<ffffffffa040f068>] 0xffffffffa040f068
[<ffffffff81002c41>] do_one_initcall+0x141/0x780
[<ffffffff816a72c3>] do_init_module+0x1c3/0x630
[<ffffffff816adb9e>] load_module+0x623e/0x76a0
[<ffffffff816af471>] __do_sys_finit_module+0x181/0x240
[<ffffffff89978f99>] do_syscall_64+0x39/0xb0
[<ffffffff89a0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- lib/test_firmware.c | 1 + 1 file changed, 1 insertion(+)
lib/test_firmware.c +1 -0
@@ -1111,6 +1111,7 @@ static int __init test_firmware_init(void) rc =misc_register (&test_fw_misc_device);if (rc) { +__test_firmware_config_free ();kfree (test_fw_config);pr_err ("could not register misc device: %d\n" , rc);return rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 466/731 misc: ocxl: fix possible name leak in ocxl_file_register_afu()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit a4cb1004aeed2ab893a058fad00a5b41a12c4691 ]
If device_register() returns error in ocxl_file_register_afu(), the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(), and info is freed in info_release().
--- drivers/misc/ocxl/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/misc/ocxl/file.c +5 -2
@@ -543,8 +543,11 @@ int ocxl_file_register_afu(struct ocxl_afu *afu) goto err_put; rc =device_register (&info->dev); -if (rc) - goto err_put; +if (rc) { +free_minor (info); +put_device (&info->dev); +return rc; + } rc =ocxl_sysfs_register_afu (info);if (rc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 467/731 ocxl: fix pci device refcount leak when calling get_function_0()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 27158c72678b39ee01cc01de1aba6b51c71abe2f ]
get_function_0() calls pci_get_domain_bus_and_slot(), as comment says, it returns a pci device with refcount increment, so after using it, pci_dev_put() needs be called.
Get the device reference when get_function_0() is not called, so pci_dev_put() can be called in the error path and callers unconditionally. And add comment above get_dvsec_vendor0() to tell callers to call pci_dev_put().
--- drivers/misc/ocxl/config.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/misc/ocxl/config.c +19 -1
@@ -204,6 +204,18 @@ static int read_dvsec_vendor(struct pci_dev *dev)return 0 ; } +/** +* get_dvsec_vendor0() - Find a related PCI device (function 0) +* @dev: PCI device to match +* @dev0: The PCI device (function 0) found +* @out_pos: The position of PCI device (function 0) +* +* Returns 0 on success, negative on failure. +* +* NOTE: If it's successful, the reference of dev0 is increased, +* so after using it, the callers must call pci_dev_put() to give +* up the reference. +*/ static int get_dvsec_vendor0 (struct pci_dev *dev,struct pci_dev **dev0,int *out_pos) {
@@ -213,10 +225,14 @@ static int get_dvsec_vendor0(struct pci_dev *dev, struct pci_dev **dev0, dev =get_function_0 (dev);if (!dev)return -1 ; + }else { + dev =pci_dev_get (dev); } pos =find_dvsec (dev,OCXL_DVSEC_VENDOR_ID ); -if (!pos) +if (!pos) { +pci_dev_put (dev);return -1 ; + } *dev0 = dev; *out_pos = pos;return 0 ;
@@ -233,6 +249,7 @@ int ocxl_config_get_reset_reload(struct pci_dev *dev, int *val)pci_read_config_dword (dev0, pos +OCXL_DVSEC_VENDOR_RESET_RELOAD , &reset_reload); +pci_dev_put (dev0); *val = !!(reset_reload &BIT (0 ));return 0 ; }
@@ -254,6 +271,7 @@ int ocxl_config_set_reset_reload(struct pci_dev *dev, int val) reset_reload &= ~BIT (0 );pci_write_config_dword (dev0, pos +OCXL_DVSEC_VENDOR_RESET_RELOAD , reset_reload); +pci_dev_put (dev0);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 468/731 misc: tifm: fix possible memory leak in tifm_7xx1_switch_media()
In reply to Greg Kroah-HartmanFrom: ruanjinjie <[email protected]>
[ Upstream commit fd2c930cf6a5b9176382c15f9acb1996e76e25ad ]
If device_register() returns error in tifm_7xx1_switch_media(), name of kobject which is allocated in dev_set_name() called in device_add() is leaked.
Never directly free @dev after calling device_register(), even if it returned an error! Always use put_device() to give up the reference initialized.
--- drivers/misc/tifm_7xx1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/tifm_7xx1.c +1 -1
@@ -190,7 +190,7 @@ static void tifm_7xx1_switch_media(struct work_struct *work)spin_unlock_irqrestore (&fm->lock, flags); }if (sock) -tifm_free_device (&sock->dev); +put_device (&sock->dev); }spin_lock_irqsave (&fm->lock, flags); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 469/731 misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and gru_handle_user_call_os
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
[ Upstream commit 643a16a0eb1d6ac23744bb6e90a00fc21148a9dc ]
In some bad situation, the gts may be freed gru_check_chiplet_assignment. The call chain can be gru_unload_context->gru_free_gru_context->gts_drop and kfree finally. However, the caller didn't know if the gts is freed or not and use it afterwards. This will trigger a Use after Free bug.
Fix it by introducing a return value to see if it's in error path or not. Free the gts in caller if gru_check_chiplet_assignment check failed.
--- drivers/misc/sgi-gru/grufault.c | 13 +++++++++++-- drivers/misc/sgi-gru/grumain.c | 22 ++++++++++++++++++---- drivers/misc/sgi-gru/grutables.h | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-)
drivers/misc/sgi-gru/grufault.c +11 -2
@@ -648,6 +648,7 @@ int gru_handle_user_call_os(unsigned long cb)if ((cb & (GRU_HANDLE_STRIDE -1 )) || ucbnum >=GRU_NUM_CB )return -EINVAL ; +again: gts =gru_find_lock_gts (cb);if (!gts)return -EINVAL ;
@@ -656,7 +657,11 @@ int gru_handle_user_call_os(unsigned long cb)if (ucbnum >= gts->ts_cbr_au_count *GRU_CBR_AU_SIZE ) goto exit; -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +gru_unlock_gts (gts); +gru_unload_context (gts,1 ); + goto again; + }/* * CCH may contain stale data if ts_force_cch_reload is set.
@@ -874,7 +879,11 @@ int gru_set_context_option(unsigned long arg) }else { gts->ts_user_blade_id = req.val1; gts->ts_user_chiplet_id = req.val0; -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +gru_unlock_gts (gts); +gru_unload_context (gts,1 ); +return ret; + } }break ;case sco_gseg_owner:
drivers/misc/sgi-gru/grumain.c +18 -4
@@ -716,9 +716,10 @@ static int gru_check_chiplet_assignment(struct gru_state *gru,* chiplet. Misassignment can occur if the process migrates to a different * blade or if the user changes the selected blade/chiplet. */ -void gru_check_context_placement (struct gru_thread_state *gts) +int gru_check_context_placement (struct gru_thread_state *gts) {struct gru_state *gru; +int ret =0 ;/* * If the current task is the context owner, verify that the
@@ -726,15 +727,23 @@ void gru_check_context_placement(struct gru_thread_state *gts)* references. Pthread apps use non-owner references to the CBRs. */ gru = gts->ts_gru; +/* +* If gru or gts->ts_tgid_owner isn't initialized properly, return +* success to indicate that the caller does not need to unload the +* gru context.The caller is responsible for their inspection and +* reinitialization if needed. +*/ if (!gru || gts->ts_tgid_owner != current->tgid) -return ; +return ret;if (!gru_check_chiplet_assignment (gru, gts)) {STAT (check_context_unload); -gru_unload_context (gts,1 ); + ret = -EINVAL ; }else if (gru_retarget_intr (gts)) {STAT (check_context_retarget_intr); } + +return ret; }
@@ -934,7 +943,12 @@ vm_fault_t gru_fault(struct vm_fault *vmf)mutex_lock (>s->ts_ctxlock);preempt_disable (); -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +preempt_enable (); +mutex_unlock (>s->ts_ctxlock); +gru_unload_context (gts,1 ); +return VM_FAULT_NOPAGE ; + }if (!gts->ts_gru) {STAT (load_user_context);
drivers/misc/sgi-gru/grutables.h +1 -1
@@ -638,7 +638,7 @@ extern int gru_user_flush_tlb(unsigned long arg);extern int gru_user_unload_context (unsigned long arg);extern int gru_get_exception_detail (unsigned long arg);extern int gru_set_context_option (unsigned long address); -extern void gru_check_context_placement (struct gru_thread_state *gts); +extern int gru_check_context_placement (struct gru_thread_state *gts);extern int gru_cpu_fault_map_id (void );extern struct vm_area_struct *gru_find_vma (unsigned long vaddr);extern void gru_flush_all_tlb (struct gru_state *gru);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 470/731 firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 7b51161696e803fd5f9ad55b20a64c2df313f95c ]
In rpi_firmware_probe(), if mbox_request_channel() fails, the 'fw' will not be freed through rpi_firmware_delete(), fix this leak by calling kfree() in the error path.
--- drivers/firmware/raspberrypi.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/raspberrypi.c +1 -0
@@ -272,6 +272,7 @@ static int rpi_firmware_probe(struct platform_device *pdev)int ret =PTR_ERR (fw->chan);if (ret != -EPROBE_DEFER )dev_err (dev,"Failed to get mbox channel: %d\n" , ret); +kfree (fw);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 471/731 cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 61c80d1c3833e196256fb060382db94f24d3d9a7 ]
If device_register() fails in cxl_register_afu|adapter(), the device is not added, device_unregister() can not be called in the error path, otherwise it will cause a null-ptr-deref because of removing not added device.
As comment of device_register() says, it should use put_device() to give up the reference in the error path. So split device_unregister() into device_del() and put_device(), then goes to put dev when register fails.
--- drivers/misc/cxl/guest.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/misc/cxl/guest.c +14 -10
@@ -959,10 +959,10 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_n* if it returns an error! */ if ((rc =cxl_register_afu (afu))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_afu_add (afu))) - goto err_put1; + goto err_del_dev;/* * pHyp doesn't expose the programming models supported by the
@@ -978,7 +978,7 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_n afu->modes_supported =CXL_MODE_DIRECTED ;if ((rc =cxl_afu_select_best_mode (afu))) - goto err_put2; + goto err_remove_sysfs; adapter->afu[afu->slice] = afu;
@@ -998,10 +998,12 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_nreturn 0 ; -err_put2: +err_remove_sysfs:cxl_sysfs_afu_remove (afu); -err_put1: -device_unregister (&afu->dev); +err_del_dev: +device_del (&afu->dev); +err_put_dev: +put_device (&afu->dev); free = false;guest_release_serr_irq (afu); err2:
@@ -1135,18 +1137,20 @@ struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_devic* even if it returns an error! */ if ((rc =cxl_register_adapter (adapter))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_adapter_add (adapter))) - goto err_put1; + goto err_del_dev;/* release the context lock as the adapter is configured */ cxl_adapter_context_unlock (adapter);return adapter; -err_put1: -device_unregister (&adapter->dev); +err_del_dev: +device_del (&adapter->dev); +err_put_dev: +put_device (&adapter->dev); free = false;cxl_guest_remove_chardev (adapter); err1:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 472/731 cxl: fix possible null-ptr-deref in cxl_pci_init_afu|adapter()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 02cd3032b154fa02fdf90e7467abaeed889330b2 ]
If device_register() fails in cxl_pci_afu|adapter(), the device is not added, device_unregister() can not be called in the error path, otherwise it will cause a null-ptr-deref because of removing not added device.
As comment of device_register() says, it should use put_device() to give up the reference in the error path. So split device_unregister() into device_del() and put_device(), then goes to put dev when register fails.
--- drivers/misc/cxl/pci.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/misc/cxl/pci.c +12 -8
@@ -1164,10 +1164,10 @@ static int pci_init_afu(struct cxl *adapter, int slice, struct pci_dev *dev)* if it returns an error! */ if ((rc =cxl_register_afu (afu))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_afu_add (afu))) - goto err_put1; + goto err_del_dev; adapter->afu[afu->slice] = afu;
@@ -1176,10 +1176,12 @@ static int pci_init_afu(struct cxl *adapter, int slice, struct pci_dev *dev)return 0 ; -err_put1: +err_del_dev: +device_del (&afu->dev); +err_put_dev:pci_deconfigure_afu (afu);cxl_debugfs_afu_remove (afu); -device_unregister (&afu->dev); +put_device (&afu->dev);return rc; err_free_native:
@@ -1667,23 +1669,25 @@ static struct cxl *cxl_pci_init_adapter(struct pci_dev *dev)* even if it returns an error! */ if ((rc =cxl_register_adapter (adapter))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_adapter_add (adapter))) - goto err_put1; + goto err_del_dev;/* Release the context lock as adapter is configured */ cxl_adapter_context_unlock (adapter);return adapter; -err_put1: +err_del_dev: +device_del (&adapter->dev); +err_put_dev:/* This should mirror cxl_remove_adapter, except without the * sysfs parts */ cxl_debugfs_adapter_remove (adapter);cxl_deconfigure_adapter (adapter); -device_unregister (&adapter->dev); +put_device (&adapter->dev);return ERR_PTR (rc); err_release:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 473/731 iio: temperature: ltc2983: make bulk write buffer DMA-safe
In reply to Greg Kroah-HartmanFrom: Cosmin Tanislav <[email protected]>
[ Upstream commit 5e0176213949724fbe9a8e4a39817edce337b8a0 ]
regmap_bulk_write() does not guarantee implicit DMA-safety, even though the current implementation duplicates the given buffer. Do not rely on it.
--- drivers/iio/temperature/ltc2983.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/temperature/ltc2983.c +5 -5
@@ -205,6 +205,7 @@ struct ltc2983_data {* Holds the converted temperature */ __be32 temp____cacheline_aligned ; +__be32 chan_val; };struct ltc2983_sensor {
@@ -309,19 +310,18 @@ static int __ltc2983_fault_handler(const struct ltc2983_data *st,return 0 ; } -static int __ltc2983_chan_assign_common (const struct ltc2983_data *st, +static int __ltc2983_chan_assign_common (struct ltc2983_data *st,const struct ltc2983_sensor *sensor,u32 chan_val) {u32 reg =LTC2983_CHAN_START_ADDR (sensor->chan); -__be32 __chan_val; chan_val |=LTC2983_CHAN_TYPE (sensor->type);dev_dbg (&st->spi->dev,"Assign reg:0x%04X, val:0x%08X\n" , reg, chan_val); - __chan_val =cpu_to_be32 (chan_val); -return regmap_bulk_write (st->regmap, reg, &__chan_val, -sizeof (__chan_val)); + st->chan_val =cpu_to_be32 (chan_val); +return regmap_bulk_write (st->regmap, reg, &st->chan_val, +sizeof (st->chan_val)); } static int __ltc2983_chan_custom_sensor_assign(struct ltc2983_data *st,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 474/731 iio: adis: handle devices that cannot unmask the drdy pin
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
[ Upstream commit 31fa357ac809affd9f9a7d0b5d1991951e16beec ]
Some devices can't mask/unmask the data ready pin and in those cases each driver was just calling '{dis}enable_irq()' to control the trigger state. This change, moves that handling into the library by introducing a new boolean in the data structure that tells the library that the device cannot unmask the pin.
On top of controlling the trigger state, we can also use this flag to automatically request the IRQ with 'IRQF_NO_AUTOEN' in case it is set. So far, all users of the library want to start operation with IRQs/DRDY pin disabled so it should be fairly safe to do this inside the library.
Stable-dep-of: 99c05e4283a1 ("iio: adis: add '__adis_enable_irq()' implementation")
--- drivers/iio/imu/adis.c | 15 ++++++++++++++- drivers/iio/imu/adis_trigger.c | 4 ++++ include/linux/iio/imu/adis.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-)
drivers/iio/imu/adis.c +14 -1
@@ -286,6 +286,13 @@ int adis_enable_irq(struct adis *adis, bool enable)if (adis->data->enable_irq) { ret = adis->data->enable_irq (adis, enable); goto out_unlock; + }else if (adis->data->unmasked_drdy) { +if (enable) +enable_irq (adis->spi->irq); +else +disable_irq (adis->spi->irq); + + goto out_unlock; } ret =__adis_read_reg_16 (adis, adis->data->msc_ctrl_reg, &msc);
@@ -430,7 +437,13 @@ int __adis_initial_startup(struct adis *adis)if (ret)return ret; -adis_enable_irq (adis, false); +/* +* don't bother calling this if we can't unmask the IRQ as in this case +* the IRQ is most likely not yet requested and we will request it +* with 'IRQF_NO_AUTOEN' anyways. +*/ +if (!adis->data->unmasked_drdy) +adis_enable_irq (adis, false);if (!adis->data->prod_id_reg)return 0 ;
drivers/iio/imu/adis_trigger.c +4 -0
@@ -30,6 +30,10 @@ static const struct iio_trigger_ops adis_trigger_ops = {static int adis_validate_irq_flag (struct adis *adis) {unsigned long direction = adis->irq_flag &IRQF_TRIGGER_MASK ; + +/* We cannot mask the interrupt so ensure it's not enabled at request */ +if (adis->data->unmasked_drdy) + adis->irq_flag |=IRQF_NO_AUTOEN ;/* * Typically this devices have data ready either on the rising edge or * on the falling edge of the data ready pin. This checks enforces that
include/linux/iio/imu/adis.h +2 -0
@@ -49,6 +49,7 @@ struct adis_timeout {* @status_error_mask: Bitmask of errors supported by the device * @timeouts: Chip specific delays * @enable_irq: Hook for ADIS devices that have a special IRQ enable/disable +* @unmasked_drdy: True for devices that cannot mask/unmask the data ready pin * @has_paging: True if ADIS device has paged registers * @burst_reg_cmd: Register command that triggers burst * @burst_len: Burst size in the SPI RX buffer. If @burst_max_len is defined,
@@ -78,6 +79,7 @@ struct adis_data {unsigned int status_error_mask;int (*enable_irq)(struct adis *adis,bool enable); +bool unmasked_drdy;bool has_paging;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 475/731 iio: adis: stylistic changes
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
[ Upstream commit c39010ea6ba13bdf0003bd353e1d4c663aaac0a8 ]
Minor stylistic changes to address checkptach complains when called with '--strict'.
Stable-dep-of: 99c05e4283a1 ("iio: adis: add '__adis_enable_irq()' implementation")
--- drivers/iio/imu/adis.c | 47 +++++++++++++++++---------------- drivers/iio/imu/adis_buffer.c | 6 ++--- drivers/iio/imu/adis_trigger.c | 3 +-- include/linux/iio/imu/adis.h | 48 ++++++++++++++++++---------------- 4 files changed, 54 insertions(+), 50 deletions(-)
drivers/iio/imu/adis.c +25 -22
@@ -30,8 +30,8 @@* @value: The value to write to device (up to 4 bytes) * @size: The size of the @value (in bytes) */ -int __adis_write_reg (struct adis *adis,unsigned int reg, -unsigned int value,unsigned int size) +int __adis_write_reg (struct adis *adis,unsigned int reg,unsigned int value, +unsigned int size) {unsigned int page = reg /ADIS_PAGE_SIZE ;int ret, i;
@@ -114,7 +114,7 @@ int __adis_write_reg(struct adis *adis, unsigned int reg, ret =spi_sync (adis->spi, &msg);if (ret) {dev_err (&adis->spi->dev,"Failed to write register 0x%02X: %d\n" , - reg, ret); + reg, ret); }else { adis->current_page = page; }
@@ -130,8 +130,8 @@ EXPORT_SYMBOL_GPL(__adis_write_reg);* @val: The value read back from the device * @size: The size of the @val buffer */ -int __adis_read_reg (struct adis *adis,unsigned int reg, -unsigned int *val,unsigned int size) +int __adis_read_reg (struct adis *adis,unsigned int reg,unsigned int *val, +unsigned int size) {unsigned int page = reg /ADIS_PAGE_SIZE ;struct spi_message msg;
@@ -201,12 +201,12 @@ int __adis_read_reg(struct adis *adis, unsigned int reg, ret =spi_sync (adis->spi, &msg);if (ret) {dev_err (&adis->spi->dev,"Failed to read register 0x%02X: %d\n" , - reg, ret); + reg, ret);return ret; - }else { - adis->current_page = page; } + adis->current_page = page; +switch (size) {case 4 : *val =get_unaligned_be32 (adis->rx);
@@ -247,13 +247,13 @@ EXPORT_SYMBOL_GPL(__adis_update_bits_base);#ifdef CONFIG_DEBUG_FS -int adis_debugfs_reg_access (struct iio_dev *indio_dev, -unsigned int reg,unsigned int writeval,unsigned int *readval) +int adis_debugfs_reg_access (struct iio_dev *indio_dev,unsigned int reg, +unsigned int writeval,unsigned int *readval) {struct adis *adis =iio_device_get_drvdata (indio_dev);if (readval) { -uint16_t val16; +u16 val16;int ret; ret =adis_read_reg_16 (adis, reg, &val16);
@@ -261,9 +261,9 @@ int adis_debugfs_reg_access(struct iio_dev *indio_dev, *readval = val16;return ret; - }else { -return adis_write_reg_16 (adis, reg, writeval); } + +return adis_write_reg_16 (adis, reg, writeval); }EXPORT_SYMBOL (adis_debugfs_reg_access);
@@ -279,14 +279,16 @@ EXPORT_SYMBOL(adis_debugfs_reg_access);int adis_enable_irq (struct adis *adis,bool enable) {int ret =0 ; -uint16_t msc; +u16 msc;mutex_lock (&adis->state_lock);if (adis->data->enable_irq) { ret = adis->data->enable_irq (adis, enable); goto out_unlock; - }else if (adis->data->unmasked_drdy) { + } + +if (adis->data->unmasked_drdy) {if (enable)enable_irq (adis->spi->irq);else
@@ -322,7 +324,7 @@ EXPORT_SYMBOL(adis_enable_irq);*/ int __adis_check_status (struct adis *adis) { -uint16_t status; +u16 status;int ret;int i;
@@ -358,7 +360,7 @@ int __adis_reset(struct adis *adis)const struct adis_timeout *timeouts = adis->data->timeouts; ret =__adis_write_reg_8 (adis, adis->data->glob_cmd_reg, -ADIS_GLOB_CMD_SW_RESET ); +ADIS_GLOB_CMD_SW_RESET );if (ret) {dev_err (&adis->spi->dev,"Failed to reset device: %d\n" , ret);return ret;
@@ -414,7 +416,7 @@ int __adis_initial_startup(struct adis *adis) {const struct adis_timeout *timeouts = adis->data->timeouts;struct gpio_desc *gpio; -uint16_t prod_id; +u16 prod_id;int ret;/* check if the device has rst pin low */
@@ -423,7 +425,7 @@ int __adis_initial_startup(struct adis *adis)return PTR_ERR (gpio);if (gpio) { -msleep (10 ); +usleep_range (10 ,12 );/* bring device out of reset */ gpiod_set_value_cansleep (gpio,0 );msleep (timeouts->reset_ms);
@@ -477,7 +479,8 @@ EXPORT_SYMBOL_GPL(__adis_initial_startup);* a error bit in the channels raw value set error_mask to 0. */ int adis_single_conversion (struct iio_dev *indio_dev, -const struct iio_chan_spec *chan,unsigned int error_mask,int *val) +const struct iio_chan_spec *chan, +unsigned int error_mask,int *val) {struct adis *adis =iio_device_get_drvdata (indio_dev);unsigned int uval;
@@ -486,7 +489,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,mutex_lock (&adis->state_lock); ret =__adis_read_reg (adis, chan->address, &uval, - chan->scan_type.storagebits /8 ); + chan->scan_type.storagebits /8 );if (ret) goto err_unlock;
@@ -521,7 +524,7 @@ EXPORT_SYMBOL_GPL(adis_single_conversion);* called. */ int adis_init (struct adis *adis,struct iio_dev *indio_dev, -struct spi_device *spi,const struct adis_data *data) +struct spi_device *spi,const struct adis_data *data) {if (!data || !data->timeouts) {dev_err (&spi->dev,"No config data or timeouts not defined!\n" );
drivers/iio/imu/adis_buffer.c +3 -3
@@ -20,7 +20,7 @@#include <linux/iio/imu/adis.h> static int adis_update_scan_mode_burst (struct iio_dev *indio_dev, -const unsigned long *scan_mask) +const unsigned long *scan_mask) {struct adis *adis =iio_device_get_drvdata (indio_dev);unsigned int burst_length, burst_max_length;
@@ -67,7 +67,7 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev, }int adis_update_scan_mode (struct iio_dev *indio_dev, -const unsigned long *scan_mask) +const unsigned long *scan_mask) {struct adis *adis =iio_device_get_drvdata (indio_dev);const struct iio_chan_spec *chan;
@@ -158,7 +158,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p) }iio_push_to_buffers_with_timestamp (indio_dev, adis->buffer, - pf->timestamp); + pf->timestamp); irq_done:iio_trigger_notify_done (indio_dev->trig);
drivers/iio/imu/adis_trigger.c +1 -2
@@ -15,8 +15,7 @@#include <linux/iio/trigger.h> #include <linux/iio/imu/adis.h> -static int adis_data_rdy_trigger_set_state (struct iio_trigger *trig, -bool state) +static int adis_data_rdy_trigger_set_state (struct iio_trigger *trig,bool state) {struct adis *adis =iio_trigger_get_drvdata (trig);
include/linux/iio/imu/adis.h +25 -23
172 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 476/731 iio:imu:adis: Move exports into IIO_ADISLIB namespace
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
[ Upstream commit 6c9304d6af122f9afea41885ad82ed627e9442a8 ]
In order to avoid unneessary pollution of the global symbol namespace move the common/library functions into a specific namespace and import that into the various specific device drivers that use them.
Stable-dep-of: 99c05e4283a1 ("iio: adis: add '__adis_enable_irq()' implementation")
--- drivers/iio/accel/adis16201.c | 1 + drivers/iio/accel/adis16209.c | 1 + drivers/iio/gyro/adis16136.c | 1 + drivers/iio/gyro/adis16260.c | 1 + drivers/iio/imu/adis.c | 20 ++++++++++---------- drivers/iio/imu/adis16400.c | 1 + drivers/iio/imu/adis16460.c | 1 + drivers/iio/imu/adis16475.c | 1 + drivers/iio/imu/adis16480.c | 1 + drivers/iio/imu/adis_buffer.c | 4 ++-- drivers/iio/imu/adis_trigger.c | 2 +- drivers/staging/iio/accel/adis16203.c | 1 + drivers/staging/iio/accel/adis16240.c | 1 + 13 files changed, 23 insertions(+), 13 deletions(-)
drivers/iio/accel/adis16201.c +1 -0
@@ -300,3 +300,4 @@ MODULE_AUTHOR("Barry Song <[email protected]>");MODULE_DESCRIPTION ("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer" );MODULE_LICENSE ("GPL v2" );MODULE_ALIAS ("spi:adis16201" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/accel/adis16209.c +1 -0
@@ -310,3 +310,4 @@ MODULE_AUTHOR("Barry Song <[email protected]>");MODULE_DESCRIPTION ("Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" );MODULE_LICENSE ("GPL v2" );MODULE_ALIAS ("spi:adis16209" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/gyro/adis16136.c +1 -0
@@ -591,3 +591,4 @@ module_spi_driver(adis16136_driver);MODULE_AUTHOR ("Lars-Peter Clausen <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16133/ADIS16135/ADIS16136 gyroscope driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/gyro/adis16260.c +1 -0
@@ -433,3 +433,4 @@ module_spi_driver(adis16260_driver);MODULE_AUTHOR ("Barry Song <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16260/5 Digital Gyroscope Sensor" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/imu/adis.c +10 -10
@@ -121,7 +121,7 @@ int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,return ret; } -EXPORT_SYMBOL_GPL (__adis_write_reg); +EXPORT_SYMBOL_NS_GPL (__adis_write_reg,IIO_ADISLIB );/** * __adis_read_reg() - read N bytes from register (unlocked version)
@@ -218,7 +218,7 @@ int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val,return ret; } -EXPORT_SYMBOL_GPL (__adis_read_reg); +EXPORT_SYMBOL_NS_GPL (__adis_read_reg,IIO_ADISLIB );/** * __adis_update_bits_base() - ADIS Update bits function - Unlocked version * @adis: The adis device
@@ -243,7 +243,7 @@ int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask,return __adis_write_reg (adis, reg, __val, size); } -EXPORT_SYMBOL_GPL (__adis_update_bits_base); +EXPORT_SYMBOL_NS_GPL (__adis_update_bits_base,IIO_ADISLIB );#ifdef CONFIG_DEBUG_FS
@@ -265,7 +265,7 @@ int adis_debugfs_reg_access(struct iio_dev *indio_dev, unsigned int reg, return adis_write_reg_16(adis, reg, writeval); } -EXPORT_SYMBOL (adis_debugfs_reg_access); +EXPORT_SYMBOL_NS (adis_debugfs_reg_access,IIO_ADISLIB );#endif
@@ -314,7 +314,7 @@ int adis_enable_irq(struct adis *adis, bool enable)mutex_unlock (&adis->state_lock);return ret; } -EXPORT_SYMBOL (adis_enable_irq); +EXPORT_SYMBOL_NS (adis_enable_irq,IIO_ADISLIB );/** * __adis_check_status() - Check the device for error conditions (unlocked)
@@ -346,7 +346,7 @@ int __adis_check_status(struct adis *adis)return -EIO ; } -EXPORT_SYMBOL_GPL (__adis_check_status); +EXPORT_SYMBOL_NS_GPL (__adis_check_status,IIO_ADISLIB );/** * __adis_reset() - Reset the device (unlocked version)
@@ -370,7 +370,7 @@ int __adis_reset(struct adis *adis)return 0 ; } -EXPORT_SYMBOL_GPL (__adis_reset); +EXPORT_SYMBOL_NS_GPL (__adis_reset,IIO_ADIS_LIB );static int adis_self_test (struct adis *adis) {
@@ -461,7 +461,7 @@ int __adis_initial_startup(struct adis *adis)return 0 ; } -EXPORT_SYMBOL_GPL (__adis_initial_startup); +EXPORT_SYMBOL_NS_GPL (__adis_initial_startup,IIO_ADISLIB );/** * adis_single_conversion() - Performs a single sample conversion
@@ -509,7 +509,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,mutex_unlock (&adis->state_lock);return ret; } -EXPORT_SYMBOL_GPL (adis_single_conversion); +EXPORT_SYMBOL_NS_GPL (adis_single_conversion,IIO_ADISLIB );/** * adis_init() - Initialize adis device structure
@@ -546,7 +546,7 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev,return 0 ; } -EXPORT_SYMBOL_GPL (adis_init); +EXPORT_SYMBOL_NS_GPL (adis_init,IIO_ADISLIB );MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Lars-Peter Clausen <[email protected]>" );
drivers/iio/imu/adis16400.c +1 -0
@@ -1230,3 +1230,4 @@ module_spi_driver(adis16400_driver);MODULE_AUTHOR ("Manuel Stahl <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16400/5 IMU SPI driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/imu/adis16460.c +1 -0
@@ -444,3 +444,4 @@ module_spi_driver(adis16460_driver);MODULE_AUTHOR ("Dragos Bogdan <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16460 IMU driver" );MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/imu/adis16475.c +1 -0
@@ -1382,3 +1382,4 @@ module_spi_driver(adis16475_driver);MODULE_AUTHOR ("Nuno Sa <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16475 IMU driver" );MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/imu/adis16480.c +1 -0
@@ -1538,3 +1538,4 @@ module_spi_driver(adis16480_driver);MODULE_AUTHOR ("Lars-Peter Clausen <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16480 IMU driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/iio/imu/adis_buffer.c +2 -2
@@ -124,7 +124,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,return 0 ; } -EXPORT_SYMBOL_GPL (adis_update_scan_mode); +EXPORT_SYMBOL_NS_GPL (adis_update_scan_mode,IIO_ADISLIB );static irqreturn_t adis_trigger_handler (int irq,void *p) {
@@ -212,5 +212,5 @@ devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev,return devm_add_action_or_reset (&adis->spi->dev, adis_buffer_cleanup, adis); } -EXPORT_SYMBOL_GPL (devm_adis_setup_buffer_and_trigger); +EXPORT_SYMBOL_NS_GPL (devm_adis_setup_buffer_and_trigger,IIO_ADISLIB );
drivers/iio/imu/adis_trigger.c +1 -1
@@ -87,5 +87,5 @@ int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)return devm_iio_trigger_register (&adis->spi->dev, adis->trig); } -EXPORT_SYMBOL_GPL (devm_adis_probe_trigger); +EXPORT_SYMBOL_NS_GPL (devm_adis_probe_trigger,IIO_ADISLIB );
drivers/staging/iio/accel/adis16203.c +1 -0
@@ -312,3 +312,4 @@ MODULE_AUTHOR("Barry Song <[email protected]>");MODULE_DESCRIPTION ("Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer" );MODULE_LICENSE ("GPL v2" );MODULE_ALIAS ("spi:adis16203" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
drivers/staging/iio/accel/adis16240.c +1 -0
@@ -440,3 +440,4 @@ MODULE_AUTHOR("Barry Song <[email protected]>");MODULE_DESCRIPTION ("Analog Devices Programmable Impact Sensor and Recorder" );MODULE_LICENSE ("GPL v2" );MODULE_ALIAS ("spi:adis16240" ); +MODULE_IMPORT_NS (IIO_ADISLIB );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 477/731 iio: adis: add __adis_enable_irq() implementation
In reply to Greg Kroah-HartmanFrom: Ramona Bolboaca <[email protected]>
[ Upstream commit 99c05e4283a19a02a256f14100ca4ec3b2da3f62 ]
Add '__adis_enable_irq()' implementation which is the unlocked version of 'adis_enable_irq()'.
Call '__adis_enable_irq()' instead of 'adis_enable_irq()' from '__adis_intial_startup()' to keep the expected unlocked functionality.
This fix is needed to remove a deadlock for all devices which are using 'adis_initial_startup()'. The deadlock occurs because the same mutex is acquired twice, without releasing it.
The mutex is acquired once inside 'adis_initial_startup()', before calling '__adis_initial_startup()', and once inside 'adis_enable_irq()', which is called by '__adis_initial_startup()'. The deadlock is removed by calling '__adis_enable_irq()', instead of 'adis_enable_irq()' from within '__adis_initial_startup()'.
--- drivers/iio/imu/adis.c | 28 ++++++++++------------------ include/linux/iio/imu/adis.h | 13 ++++++++++++- 2 files changed, 22 insertions(+), 19 deletions(-)
drivers/iio/imu/adis.c +10 -18
@@ -270,23 +270,19 @@ EXPORT_SYMBOL_NS(adis_debugfs_reg_access, IIO_ADISLIB);#endif /** -* adis_enable_irq() - Enable or disable data ready IRQ +* __adis_enable_irq() - Enable or disable data ready IRQ (unlocked) * @adis: The adis device * @enable: Whether to enable the IRQ * * Returns 0 on success, negative error code otherwise */ -int adis_enable_irq (struct adis *adis,bool enable) +int __adis_enable_irq (struct adis *adis,bool enable) { -int ret =0 ; +int ret;u16 msc; -mutex_lock (&adis->state_lock); - -if (adis->data->enable_irq) { - ret = adis->data->enable_irq (adis, enable); - goto out_unlock; - } +if (adis->data->enable_irq) +return adis->data->enable_irq (adis, enable);if (adis->data->unmasked_drdy) {if (enable)
@@ -294,12 +290,12 @@ int adis_enable_irq(struct adis *adis, bool enable)else disable_irq (adis->spi->irq); - goto out_unlock; +return 0 ; } ret =__adis_read_reg_16 (adis, adis->data->msc_ctrl_reg, &msc);if (ret) - goto out_unlock; +return ret; msc |=ADIS_MSC_CTRL_DATA_RDY_POL_HIGH ; msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2 ;
@@ -308,13 +304,9 @@ int adis_enable_irq(struct adis *adis, bool enable)else msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN ; - ret =__adis_write_reg_16 (adis, adis->data->msc_ctrl_reg, msc); - -out_unlock: -mutex_unlock (&adis->state_lock); -return ret; +return __adis_write_reg_16 (adis, adis->data->msc_ctrl_reg, msc); } -EXPORT_SYMBOL_NS (adis_enable_irq,IIO_ADISLIB ); +EXPORT_SYMBOL_NS (__adis_enable_irq,IIO_ADISLIB );/** * __adis_check_status() - Check the device for error conditions (unlocked)
@@ -445,7 +437,7 @@ int __adis_initial_startup(struct adis *adis)* with 'IRQF_NO_AUTOEN' anyways. */ if (!adis->data->unmasked_drdy) -adis_enable_irq (adis, false); +__adis_enable_irq (adis, false);if (!adis->data->prod_id_reg)return 0 ;
include/linux/iio/imu/adis.h +12 -1
@@ -406,9 +406,20 @@ static inline int adis_update_bits_base(struct adis *adis, unsigned int reg, __adis_update_bits_base(adis, reg, mask, val, 2)); \ }) -int adis_enable_irq (struct adis *adis,bool enable);int __adis_check_status (struct adis *adis);int __adis_initial_startup (struct adis *adis); +int __adis_enable_irq (struct adis *adis,bool enable); + +static inline int adis_enable_irq (struct adis *adis,bool enable) +{ +int ret; + +mutex_lock (&adis->state_lock); + ret =__adis_enable_irq (adis, enable); +mutex_unlock (&adis->state_lock); + +return ret; +}static inline int adis_check_status (struct adis *adis) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 478/731 counter: stm32-lptimer-cnt: fix the check on arr and cmp registers update
In reply to Greg Kroah-HartmanFrom: Fabrice Gasnier <[email protected]>
[ Upstream commit fd5ac974fc25feed084c2d1599d0dddb4e0556bc ]
The ARR (auto reload register) and CMP (compare) registers are successively written. The status bits to check the update of these registers are polled together with regmap_read_poll_timeout(). The condition to end the loop may become true, even if one of the register isn't correctly updated.
So ensure both status bits are set before clearing them.
--- drivers/counter/stm32-lptimer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/counter/stm32-lptimer-cnt.c +1 -1
@@ -69,7 +69,7 @@ static int stm32_lptim_set_enable_state(struct stm32_lptim_cnt *priv,/* ensure CMP & ARR registers are properly written */ ret =regmap_read_poll_timeout (priv->regmap,STM32_LPTIM_ISR , val, - (val &STM32_LPTIM_CMPOK_ARROK ), + (val &STM32_LPTIM_CMPOK_ARROK ) ==STM32_LPTIM_CMPOK_ARROK ,100 ,1000 );if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 479/731 coresight: trbe: remove cpuhp instance node before remove cpuhp state
In reply to Greg Kroah-HartmanFrom: Yang Shen <[email protected]>
[ Upstream commit 20ee8c223f792947378196307d8e707c9cdc2d61 ]
cpuhp_state_add_instance() and cpuhp_state_remove_instance() should be used in pairs. Or there will lead to the warn on cpuhp_remove_multi_state() since the cpuhp_step list is not empty.
The following is the error log with 'rmmod coresight-trbe':
Error: Removing state 215 which has instances left.
Call trace: __cpuhp_remove_state_cpuslocked+0x144/0x160 __cpuhp_remove_state+0xac/0x100 arm_trbe_device_remove+0x2c/0x60 [coresight_trbe] platform_remove+0x34/0x70 device_remove+0x54/0x90 device_release_driver_internal+0x1e4/0x250 driver_detach+0x5c/0xb0 bus_remove_driver+0x64/0xc0 driver_unregister+0x3c/0x70 platform_driver_unregister+0x20/0x30 arm_trbe_exit+0x1c/0x658 [coresight_trbe] __arm64_sys_delete_module+0x1ac/0x24c invoke_syscall+0x50/0x120 el0_svc_common.constprop.0+0x58/0x1a0 do_el0_svc+0x38/0xd0 el0_svc+0x2c/0xc0 el0t_64_sync_handler+0x1ac/0x1b0 el0t_64_sync+0x19c/0x1a0 ---[ end trace 0000000000000000 ]---
--- drivers/hwtracing/coresight/coresight-trbe.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/coresight/coresight-trbe.c +1 -0
@@ -1030,6 +1030,7 @@ static int arm_trbe_probe_cpuhp(struct trbe_drvdata *drvdata)static void arm_trbe_remove_cpuhp (struct trbe_drvdata *drvdata) { +cpuhp_state_remove_instance (drvdata->trbe_online, &drvdata->hotplug_node);cpuhp_remove_multi_state (drvdata->trbe_online); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 480/731 usb: roles: fix of node refcount leak in usb_role_switch_is_parent()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 1ab30c610630da5391a373cddb8a065bf4c4bc01 ]
I got the following report while doing device(mt6370-tcpc) load test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/pmic@34
The 'parent' returned by fwnode_get_parent() with refcount incremented. it needs be put after using.
--- drivers/usb/roles/class.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/roles/class.c +4 -1
@@ -106,10 +106,13 @@ usb_role_switch_is_parent(struct fwnode_handle *fwnode)struct fwnode_handle *parent =fwnode_get_parent (fwnode);struct device *dev; -if (!parent || !fwnode_property_present (parent,"usb-role-switch" )) +if (!fwnode_property_present (parent,"usb-role-switch" )) { +fwnode_handle_put (parent);return NULL ; + } dev =class_find_device_by_fwnode (role_class, parent); +fwnode_handle_put (parent);return dev ?to_role_switch (dev) :ERR_PTR (-EPROBE_DEFER ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 481/731 usb: gadget: f_hid: fix f_hidg lifetime vs cdev
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit 89ff3dfac604614287ad5aad9370c3f984ea3f4b ]
The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct f_hidg, so there is a use-after-free if /dev/hidgN is held open while the gadget is deleted.
This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent):
gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&-
Pull the existing device up in to struct f_hidg and make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match struct f_hidg, but note that it is still added and deleted at the same time.
--- drivers/usb/gadget/function/f_hid.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/usb/gadget/function/f_hid.c +28 -24
@@ -71,7 +71,7 @@ struct f_hidg {wait_queue_head_t write_queue;struct usb_request *req; -int minor; +struct device dev;struct cdev cdev;struct usb_function func;
@@ -84,6 +84,14 @@ static inline struct f_hidg *func_to_hidg(struct usb_function *f) return container_of(f, struct f_hidg, func); } +static void hidg_release (struct device *dev) +{ + struct f_hidg *hidg = container_of(dev, struct f_hidg, dev); + +kfree (hidg->set_report_buf); +kfree (hidg); +} +/*-------------------------------------------------------------------------*/ /* Static descriptors */
@@ -904,9 +912,7 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)struct usb_ep *ep;struct f_hidg *hidg =func_to_hidg (f);struct usb_string *us; -struct device *device;int status; -dev_t dev;/* maybe allocate device-global string IDs, and patch descriptors */ us = usb_gstrings_attach(c->cdev, ct_func_strings,
@@ -999,21 +1005,11 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)/* create char device */ cdev_init (&hidg->cdev, &f_hidg_fops); - dev =MKDEV (major, hidg->minor); - status =cdev_add (&hidg->cdev, dev,1 ); + status =cdev_device_add (&hidg->cdev, &hidg->dev);if (status) goto fail_free_descs; - device =device_create (hidg_class,NULL , dev,NULL , -"%s%d" ,"hidg" , hidg->minor); -if (IS_ERR (device)) { - status =PTR_ERR (device); - goto del; - } -return 0 ; -del: -cdev_del (&hidg->cdev); fail_free_descs:usb_free_all_descriptors (f); fail:
@@ -1244,9 +1240,7 @@ static void hidg_free(struct usb_function *f) hidg =func_to_hidg (f); opts = container_of(f->fi, struct f_hid_opts, func_inst); -kfree (hidg->report_desc); -kfree (hidg->set_report_buf); -kfree (hidg); +put_device (&hidg->dev);mutex_lock (&opts->lock); --opts->refcnt;mutex_unlock (&opts->lock);
@@ -1256,8 +1250,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f) {struct f_hidg *hidg =func_to_hidg (f); -device_destroy (hidg_class,MKDEV (major, hidg->minor)); -cdev_del (&hidg->cdev); +cdev_device_del (&hidg->cdev, &hidg->dev);usb_free_all_descriptors (f); }
@@ -1266,6 +1259,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) {struct f_hidg *hidg;struct f_hid_opts *opts; +int ret;/* allocate and initialize one new instance */ hidg =kzalloc (sizeof (*hidg),GFP_KERNEL );
@@ -1277,17 +1271,27 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)mutex_lock (&opts->lock); ++opts->refcnt; - hidg->minor = opts->minor; +device_initialize (&hidg->dev); + hidg->dev.release = hidg_release; + hidg->dev.class = hidg_class; + hidg->dev.devt =MKDEV (major, opts->minor); + ret =dev_set_name (&hidg->dev,"hidg%d" , opts->minor); +if (ret) { + --opts->refcnt; +mutex_unlock (&opts->lock); +return ERR_PTR (ret); + } + hidg->bInterfaceSubClass = opts->subclass; hidg->bInterfaceProtocol = opts->protocol; hidg->report_length = opts->report_length; hidg->report_desc_length = opts->report_desc_length;if (opts->report_desc) { - hidg->report_desc =kmemdup (opts->report_desc, - opts->report_desc_length, -GFP_KERNEL ); + hidg->report_desc =devm_kmemdup (&hidg->dev, opts->report_desc, + opts->report_desc_length, +GFP_KERNEL );if (!hidg->report_desc) { -kfree (hidg); +put_device (&hidg->dev);mutex_unlock (&opts->lock);return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.35.1
Re: [PATCH 5.15 481/731] usb: gadget: f_hid: fix f_hidg lifetime vs cdev
Quoted 29 lines · Greg Kroah-Hartman
From: John Keeping <[email protected]>
[ Upstream commit
89ff3dfac604614287ad5aad9370c3f984ea3f4b]The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct
f_hidg, so there is a use-after-free if/dev/hidgNis held open while the gadget is deleted.This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent):
gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&-Pull the existing device up in to struct
f_hidgand make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match structf_hidg, but note that it is still added and deleted at the same time.Fixes 71adf1189469 ("USB: gadget: add HID gadget driver")Tested-by Lee Jones <[email protected]>Reviewed-by Andrzej Pietrasiewicz <[email protected]>Reviewed-by Lee Jones <[email protected]>Signed-off-by John Keeping <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
--- drivers/usb/gadget/function/f_hid.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-)
Dear Stable,
Would you be kind enough to take this back as far back as linux.4.14.y please? There is a trivial fix-up required for kernels older than v5.15, but it's the same fix-up back through v4.14.
Thanks.
---
Lee Jones [李琼斯]
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 481/731] usb: gadget: f_hid: fix f_hidg lifetime vs cdev
Quoted 35 lines · Lee Jones
Quoted 29 lines · Greg Kroah-Hartman
From: John Keeping <[email protected]>
[ Upstream commit
89ff3dfac604614287ad5aad9370c3f984ea3f4b]The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct
f_hidg, so there is a use-after-free if/dev/hidgNis held open while the gadget is deleted.This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent):
gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&-Pull the existing device up in to struct
f_hidgand make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match structf_hidg, but note that it is still added and deleted at the same time.Fixes 71adf1189469 ("USB: gadget: add HID gadget driver")Tested-by Lee Jones <[email protected]>Reviewed-by Andrzej Pietrasiewicz <[email protected]>Reviewed-by Lee Jones <[email protected]>Signed-off-by John Keeping <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>Quoted 3 lines
--- drivers/usb/gadget/function/f_hid.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-)
Quoted 5 lines
Dear Stable,
Would you be kind enough to take this back as far back as linux.4.14.y please? There is a trivial fix-up required for kernels older than v5.15, but it's the same fix-up back through v4.14.
This is already in the queue for 5.10, 5.4, and 4.19, but for some reason not in 4.14. Can you verify that the 4.19 version works there too?
thanks,
greg k-h
Re: [PATCH 5.15 481/731] usb: gadget: f_hid: fix f_hidg lifetime vs cdev
Quoted 38 lines · Greg Kroah-Hartman
Quoted 37 lines · Lee Jones
Quoted 29 lines · Greg Kroah-Hartman
From: John Keeping <[email protected]>
[ Upstream commit
89ff3dfac604614287ad5aad9370c3f984ea3f4b]The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct
f_hidg, so there is a use-after-free if/dev/hidgNis held open while the gadget is deleted.This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent):
gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&-Pull the existing device up in to struct
f_hidgand make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match structf_hidg, but note that it is still added and deleted at the same time.Fixes 71adf1189469 ("USB: gadget: add HID gadget driver")Tested-by Lee Jones <[email protected]>Reviewed-by Andrzej Pietrasiewicz <[email protected]>Reviewed-by Lee Jones <[email protected]>Signed-off-by John Keeping <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>Quoted 3 lines
--- drivers/usb/gadget/function/f_hid.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-)Dear Stable,
Quoted 7 lines
Quoted 3 lines
Would you be kind enough to take this back as far back as linux.4.14.y please? There is a trivial fix-up required for kernels older than v5.15, but it's the same fix-up back through v4.14.
This is already in the queue for 5.10, 5.4, and 4.19, but for some reason not in 4.14. Can you verify that the 4.19 version works there too?
That works. v4.19 isn't required. Thanks.
Signature · 1 line
Lee Jones [李琼斯]
Greg Kroah-Hartman
maintainerPATCH 482/731 usb: gadget: f_hid: fix refcount leak on error path
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit 70a3288a7586526315105c699b687d78cd32559a ]
When failing to allocate report_desc, opts->refcnt has already been incremented so it needs to be decremented to avoid leaving the options structure permanently locked.
--- drivers/usb/gadget/function/f_hid.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/function/f_hid.c +1 -0
@@ -1292,6 +1292,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) GFP_KERNEL);if (!hidg->report_desc) {put_device (&hidg->dev); + --opts->refcnt;mutex_unlock (&opts->lock);return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 483/731 drivers: mcb: fix resource leak in mcb_probe()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit d7237462561fcd224fa687c56ccb68629f50fc0d ]
When probe hook function failed in mcb_probe(), it doesn't put the device. Compiled test only.
--- drivers/mcb/mcb-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mcb/mcb-core.c +3 -1
@@ -71,8 +71,10 @@ static int mcb_probe(struct device *dev)get_device (dev); ret = mdrv->probe (mdev, found_id); -if (ret) +if (ret) {module_put (carrier_mod); +put_device (dev); + }return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 484/731 mcb: mcb-parse: fix error handing in chameleon_parse_gdd()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 728ac3389296caf68638628c987aeae6c8851e2d ]
If mcb_device_register() returns error in chameleon_parse_gdd(), the refcount of bus and device name are leaked. Fix this by calling put_device() to give up the reference, so they can be released in mcb_release_dev() and kobject_cleanup().
--- drivers/mcb/mcb-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mcb/mcb-parse.c +1 -1
@@ -108,7 +108,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,return 0 ; err: -mcb_free_dev (mdev); +put_device (&mdev->dev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 485/731 chardev: fix error handling in cdev_device_add()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 11fa7fefe3d8fac7da56bc9aa3dd5fb3081ca797 ]
While doing fault injection test, I got the following report:
------------[ cut here ]------------ kobject: '(null)' (0000000039956980): is not initialized, yet kobject_put() is being called. WARNING: CPU: 3 PID: 6306 at kobject_put+0x23d/0x4e0 CPU: 3 PID: 6306 Comm: 283 Tainted: G W 6.1.0-rc2-00005-g307c1086d7c9 #1253 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:kobject_put+0x23d/0x4e0 Call Trace: <TASK> cdev_device_add+0x15e/0x1b0 __iio_device_register+0x13b4/0x1af0 [industrialio] __devm_iio_device_register+0x22/0x90 [industrialio] max517_probe+0x3d8/0x6b4 [max517] i2c_device_probe+0xa81/0xc00
When device_add() is injected fault and returns error, if dev->devt is not set, cdev_add() is not called, cdev_del() is not needed. Fix this by checking dev->devt in error path.
--- fs/char_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/char_dev.c +1 -1
@@ -547,7 +547,7 @@ int cdev_device_add(struct cdev *cdev, struct device *dev) } rc =device_add (dev); -if (rc) +if (rc && dev->devt)cdev_del (cdev);return rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 486/731 i2c: pxa-pci: fix missing pci_disable_device() on error in ce4100_i2c_probe
In reply to Greg Kroah-HartmanFrom: Hui Tang <[email protected]>
[ Upstream commit d78a167332e1ca8113268ed922c1212fd71b73ad ]
Using pcim_enable_device() to avoid missing pci_disable_device().
--- drivers/i2c/busses/i2c-pxa-pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-pxa-pci.c +3 -7
@@ -105,7 +105,7 @@ static int ce4100_i2c_probe(struct pci_dev *dev,int i;struct ce4100_devices *sds; - ret =pci_enable_device_mem (dev); + ret =pcim_enable_device (dev);if (ret)return ret;
@@ -114,10 +114,8 @@ static int ce4100_i2c_probe(struct pci_dev *dev,return -EINVAL ; } sds =kzalloc (sizeof (*sds),GFP_KERNEL ); -if (!sds) { - ret = -ENOMEM ; - goto err_mem; - } +if (!sds) +return -ENOMEM ;for (i =0 ; i <ARRAY_SIZE (sds->pdev); i++) { sds->pdev[i] =add_i2c_device (dev, i);
@@ -133,8 +131,6 @@ static int ce4100_i2c_probe(struct pci_dev *dev, err_dev_add:kfree (sds); -err_mem: -pci_disable_device (dev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 487/731 staging: rtl8192u: Fix use after free in ieee80211_rx()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit bcc5e2dcf09089b337b76fc1a589f6ff95ca19ac ]
We cannot dereference the "skb" pointer after calling ieee80211_monitor_rx(), because it is a use after free.
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +3 -1
@@ -951,9 +951,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,#endif if (ieee->iw_mode ==IW_MODE_MONITOR ) { +unsigned int len = skb->len; +ieee80211_monitor_rx (ieee, skb, rx_stats); stats->rx_packets++; - stats->rx_bytes += skb->len; + stats->rx_bytes += len;return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 488/731 staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit d30f4436f364b4ad915ca2c09be07cd0f93ceb44 ]
The skb is delivered to netif_rx() in rtllib_monitor_rx(), which may free it, after calling this, dereferencing skb may trigger use-after-free. Found by Smatch.
--- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_rx.c +1 -1
@@ -1489,9 +1489,9 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen +=4 ; } -rtllib_monitor_rx (ieee, skb, rx_stats, hdrlen); ieee->stats.rx_packets++; ieee->stats.rx_bytes += skb->len; +rtllib_monitor_rx (ieee, skb, rx_stats, hdrlen);return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 489/731 vme: Fix error not catched in fake_init()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 7bef797d707f1744f71156b21d41e3b8c946631f ]
In fake_init(), __root_device_register() is possible to fail but it's ignored, which can cause unregistering vme_root fail when exit.
general protection fault, probably for non-canonical address 0xdffffc000000008c KASAN: null-ptr-deref in range [0x0000000000000460-0x0000000000000467] RIP: 0010:root_device_unregister+0x26/0x60 Call Trace: <TASK> __x64_sys_delete_module+0x34f/0x540 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
Return error when __root_device_register() fails.
--- drivers/vme/bridges/vme_fake.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/vme/bridges/vme_fake.c +2 -0
@@ -1073,6 +1073,8 @@ static int __init fake_init(void)/* We need a fake parent device */ vme_root =__root_device_register ("vme" ,THIS_MODULE ); +if (IS_ERR (vme_root)) +return PTR_ERR (vme_root);/* If we want to support more than one bridge at some point, we need to * dynamically allocate this so we get one per device.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 490/731 gpiolib: Get rid of redundant else
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 1cef8b5019769d46725932eeace7a383bca97905 ]
In the snippets like the following
if (...) return / goto / break / continue ...; else ...
the 'else' is redundant. Get rid of it. In case of IOCTLs use switch-case pattern that seems the usual in such cases.
While at it, clarify necessity of else in gpiod_direction_output() by attaching else if to the closing curly brace on a previous line.
Stable-dep-of: 533aae7c94db ("gpiolib: cdev: fix NULL-pointer dereferences")
--- drivers/gpio/gpiolib-cdev.c | 66 ++++++++++++++++++++----------------- drivers/gpio/gpiolib.c | 12 +++---- 2 files changed, 40 insertions(+), 38 deletions(-)
drivers/gpio/gpiolib-cdev.c +35 -31
@@ -197,16 +197,15 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd,void __user *ip = (void __user *)arg;struct gpiohandle_data ghd;DECLARE_BITMAP (vals,GPIOHANDLES_MAX ); -int i; +unsigned int i; +int ret; -if (cmd ==GPIOHANDLE_GET_LINE_VALUES_IOCTL ) { -/* NOTE: It's ok to read values of output lines. */ -int ret =gpiod_get_array_value_complex (false, - true, - lh->num_descs, - lh->descs, -NULL , - vals); +switch (cmd) { +case GPIOHANDLE_GET_LINE_VALUES_IOCTL : +/* NOTE: It's okay to read values of output lines */ + ret =gpiod_get_array_value_complex (false, true, + lh->num_descs, lh->descs, +NULL , vals);if (ret)return ret;
@@ -218,7 +217,7 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd,return -EFAULT ;return 0 ; - }else if (cmd ==GPIOHANDLE_SET_LINE_VALUES_IOCTL ) { +case GPIOHANDLE_SET_LINE_VALUES_IOCTL :/* * All line descriptors were created at once with the same * flags so just check if the first one is really output.
@@ -240,10 +239,11 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd, lh->descs,NULL , vals); - }else if (cmd ==GPIOHANDLE_SET_CONFIG_IOCTL ) { +case GPIOHANDLE_SET_CONFIG_IOCTL :return linehandle_set_config (lh, ip); +default : +return -EINVAL ; } -return -EINVAL ; }#ifdef CONFIG_COMPAT
@@ -1188,14 +1188,16 @@ static long linereq_ioctl(struct file *file, unsigned int cmd,struct linereq *lr = file->private_data;void __user *ip = (void __user *)arg; -if (cmd ==GPIO_V2_LINE_GET_VALUES_IOCTL ) +switch (cmd) { +case GPIO_V2_LINE_GET_VALUES_IOCTL :return linereq_get_values (lr, ip); -else if (cmd ==GPIO_V2_LINE_SET_VALUES_IOCTL ) +case GPIO_V2_LINE_SET_VALUES_IOCTL :return linereq_set_values (lr, ip); -else if (cmd ==GPIO_V2_LINE_SET_CONFIG_IOCTL ) +case GPIO_V2_LINE_SET_CONFIG_IOCTL :return linereq_set_config (lr, ip); - -return -EINVAL ; +default : +return -EINVAL ; + } }#ifdef CONFIG_COMPAT
@@ -2114,28 +2116,30 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)return -ENODEV ;/* Fill in the struct and pass to userspace */ -if (cmd ==GPIO_GET_CHIPINFO_IOCTL ) { +switch (cmd) { +case GPIO_GET_CHIPINFO_IOCTL :return chipinfo_get (cdev, ip);#ifdef CONFIG_GPIO_CDEV_V1 - }else if (cmd ==GPIO_GET_LINEHANDLE_IOCTL ) { +case GPIO_GET_LINEHANDLE_IOCTL :return linehandle_create (gdev, ip); - }else if (cmd ==GPIO_GET_LINEEVENT_IOCTL ) { +case GPIO_GET_LINEEVENT_IOCTL :return lineevent_create (gdev, ip); - }else if (cmd ==GPIO_GET_LINEINFO_IOCTL || - cmd ==GPIO_GET_LINEINFO_WATCH_IOCTL ) { -return lineinfo_get_v1 (cdev, ip, - cmd ==GPIO_GET_LINEINFO_WATCH_IOCTL ); +case GPIO_GET_LINEINFO_IOCTL : +return lineinfo_get_v1 (cdev, ip, false); +case GPIO_GET_LINEINFO_WATCH_IOCTL : +return lineinfo_get_v1 (cdev, ip, true);#endif /* CONFIG_GPIO_CDEV_V1 */ - }else if (cmd ==GPIO_V2_GET_LINEINFO_IOCTL || - cmd ==GPIO_V2_GET_LINEINFO_WATCH_IOCTL ) { -return lineinfo_get (cdev, ip, - cmd ==GPIO_V2_GET_LINEINFO_WATCH_IOCTL ); - }else if (cmd ==GPIO_V2_GET_LINE_IOCTL ) { +case GPIO_V2_GET_LINEINFO_IOCTL : +return lineinfo_get (cdev, ip, false); +case GPIO_V2_GET_LINEINFO_WATCH_IOCTL : +return lineinfo_get (cdev, ip, true); +case GPIO_V2_GET_LINE_IOCTL :return linereq_create (gdev, ip); - }else if (cmd ==GPIO_GET_LINEINFO_UNWATCH_IOCTL ) { +case GPIO_GET_LINEINFO_UNWATCH_IOCTL :return lineinfo_unwatch (cdev, ip); +default : +return -EINVAL ; } -return -EINVAL ; }#ifdef CONFIG_COMPAT
drivers/gpio/gpiolib.c +5 -7
@@ -189,9 +189,8 @@ static int gpiochip_find_base(int ngpio)/* found a free space? */ if (gdev->base + gdev->ngpio <= base)break ; -else -/* nope, check the space right before the chip */ - base = gdev->base - ngpio; +/* nope, check the space right before the chip */ + base = gdev->base - ngpio; }if (gpio_is_valid (base)) {
@@ -2410,8 +2409,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) ret =gpiod_direction_input (desc); goto set_output_flag; } - } -else if (test_bit (FLAG_OPEN_SOURCE , &desc->flags)) { + }else if (test_bit (FLAG_OPEN_SOURCE , &desc->flags)) { ret =gpio_set_config (desc,PIN_CONFIG_DRIVE_OPEN_SOURCE );if (!ret) goto set_output_value;
@@ -2568,9 +2566,9 @@ static int gpiod_get_raw_value_commit(const struct gpio_desc *desc)static int gpio_chip_get_multiple (struct gpio_chip *gc,unsigned long *mask,unsigned long *bits) { -if (gc->get_multiple) { +if (gc->get_multiple)return gc->get_multiple (gc, mask, bits); - }else if (gc->get) { +if (gc->get) {int i, value;for_each_set_bit (i, mask, gc->ngpio) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 491/731 gpiolib: cdev: fix NULL-pointer dereferences
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit 533aae7c94dbc2b14301cfd68ae7e0e90f0c8438 ]
There are several places where we can crash the kernel by requesting lines, unbinding the GPIO device, then calling any of the system calls relevant to the GPIO character device's annonymous file descriptors:ioctl(), read(), poll().
While I observed it with the GPIO simulator, it will also happen for any of the GPIO devices that can be hot-unplugged - for instance any HID GPIO expander (e.g. CP2112).
This affects both v1 and v2 uAPI.
This fixes it partially by checking if gdev->chip is not NULL but it doesn't entirely remedy the situation as we still have a race condition in which another thread can remove the device after the check.
--- drivers/gpio/gpiolib-cdev.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpio/gpiolib-cdev.c +27 -0
@@ -200,6 +200,9 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd,unsigned int i;int ret; +if (!lh->gdev->chip) +return -ENODEV ; +switch (cmd) {case GPIOHANDLE_GET_LINE_VALUES_IOCTL :/* NOTE: It's okay to read values of output lines */
@@ -1188,6 +1191,9 @@ static long linereq_ioctl(struct file *file, unsigned int cmd,struct linereq *lr = file->private_data;void __user *ip = (void __user *)arg; +if (!lr->gdev->chip) +return -ENODEV ; +switch (cmd) {case GPIO_V2_LINE_GET_VALUES_IOCTL :return linereq_get_values (lr, ip);
@@ -1214,6 +1220,9 @@ static __poll_t linereq_poll(struct file *file,struct linereq *lr = file->private_data;__poll_t events =0 ; +if (!lr->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &lr->wait, wait); if (!kfifo_is_empty_spinlocked_noirqsave(&lr->events,
@@ -1233,6 +1242,9 @@ static ssize_t linereq_read(struct file *file,ssize_t bytes_read =0 ;int ret; +if (!lr->gdev->chip) +return -ENODEV ; +if (count <sizeof (le))return -EINVAL ;
@@ -1498,6 +1510,9 @@ static __poll_t lineevent_poll(struct file *file,struct lineevent_state *le = file->private_data;__poll_t events =0 ; +if (!le->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &le->wait, wait);if (!kfifo_is_empty_spinlocked_noirqsave (&le->events, &le->wait.lock))
@@ -1522,6 +1537,9 @@ static ssize_t lineevent_read(struct file *file,ssize_t ge_size;int ret; +if (!le->gdev->chip) +return -ENODEV ; +/* * When compatible system call is being used the struct gpioevent_data, * in case of at least ia32, has different size due to the alignment
@@ -1603,6 +1621,9 @@ static long lineevent_ioctl(struct file *file, unsigned int cmd,void __user *ip = (void __user *)arg;struct gpiohandle_data ghd; +if (!le->gdev->chip) +return -ENODEV ; +/* * We can get the value for an event line but not set it, * because it is input by definition.
@@ -2187,6 +2208,9 @@ static __poll_t lineinfo_watch_poll(struct file *file,struct gpio_chardev_data *cdev = file->private_data;__poll_t events =0 ; +if (!cdev->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &cdev->wait, pollt); if (!kfifo_is_empty_spinlocked_noirqsave(&cdev->events,
@@ -2205,6 +2229,9 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,int ret;size_t event_size; +if (!cdev->gdev->chip) +return -ENODEV ; +#ifndef CONFIG_GPIO_CDEV_V1 event_size =sizeof (struct gpio_v2_line_info_changed );if (count < event_size)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 492/731 gpiolib: make struct comments into real kernel docs
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit 4398693a9e24bcab0b99ea219073917991d0792b ]
We have several comments that start with '/**' but don't conform to the kernel doc standard. Add proper detailed descriptions for the affected definitions and move the docs from the forward declarations to the struct definitions where applicable.
Stable-dep-of: bdbbae241a04 ("gpiolib: protect the GPIO device against being dropped while in use by user-space")
--- drivers/gpio/gpiolib.h | 34 ++++++++++++++++++++++++++++++++++ include/linux/gpio/consumer.h | 35 ++++++++++++++++------------------- 2 files changed, 50 insertions(+), 19 deletions(-)
drivers/gpio/gpiolib.h +34 -0
@@ -37,6 +37,9 @@* or name of the IP component in a System on Chip. * @data: per-instance data assigned by the driver * @list: links gpio_device:s together for traversal +* @notifier: used to notify subscribers about lines being requested, released +* or reconfigured +* @pin_ranges: range of pins served by the GPIO driver * * This state container holds most of the runtime variable data * for a GPIO device and can hold references and live on after the
@@ -72,6 +75,20 @@ struct gpio_device {/* gpio suffixes used for ACPI and device tree lookup */ static __maybe_unused const char *const gpio_suffixes[] = {"gpios" ,"gpio" }; +/** +* struct gpio_array - Opaque descriptor for a structure of GPIO array attributes +* +* @desc: Array of pointers to the GPIO descriptors +* @size: Number of elements in desc +* @chip: Parent GPIO chip +* @get_mask: Get mask used in fastpath +* @set_mask: Set mask used in fastpath +* @invert_mask: Invert mask used in fastpath +* +* This structure is attached to struct gpiod_descs obtained from +* gpiod_get_array() and can be passed back to get/set array functions in order +* to activate fast processing path if applicable. +*/ struct gpio_array {struct gpio_desc **desc;unsigned int size;
@@ -96,6 +113,23 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,extern spinlock_t gpio_lock;extern struct list_head gpio_devices; + +/** +* struct gpio_desc - Opaque descriptor for a GPIO +* +* @gdev: Pointer to the parent GPIO device +* @flags: Binary descriptor flags +* @label: Name of the consumer +* @name: Line name +* @hog: Pointer to the device node that hogs this line (if any) +* @debounce_period_us: Debounce period in microseconds +* +* These are obtained using gpiod_get() and are preferable to the old +* integer-based handles. +* +* Contrary to integers, a pointer to a &struct gpio_desc is guaranteed to be +* valid until the GPIO is released. +*/ struct gpio_desc {struct gpio_device *gdev;unsigned long flags;
include/linux/gpio/consumer.h +16 -19
@@ -8,27 +8,16 @@#include <linux/err.h> struct device ; - -/** -* Opaque descriptor for a GPIO. These are obtained using gpiod_get() and are -* preferable to the old integer-based handles. -* -* Contrary to integers, a pointer to a gpio_desc is guaranteed to be valid -* until the GPIO is released. -*/ struct gpio_desc ; - -/** -* Opaque descriptor for a structure of GPIO array attributes. This structure -* is attached to struct gpiod_descs obtained from gpiod_get_array() and can be -* passed back to get/set array functions in order to activate fast processing -* path if applicable. -*/ struct gpio_array ;/** -* Struct containing an array of descriptors that can be obtained using -* gpiod_get_array(). +* struct gpio_descs - Struct containing an array of descriptors that can be +* obtained using gpiod_get_array() +* +* @info: Pointer to the opaque gpio_array structure +* @ndescs: Number of held descriptors +* @desc: Array of pointers to GPIO descriptors */ struct gpio_descs {struct gpio_array *info;
@@ -43,8 +32,16 @@ struct gpio_descs {#define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4)/** -* Optional flags that can be passed to one of gpiod_* to configure direction -* and output value. These values cannot be OR'd. +* enum gpiod_flags - Optional flags that can be passed to one of gpiod_* to +* configure direction and output value. These values +* cannot be OR'd. +* +* @GPIOD_ASIS: Don't change anything +* @GPIOD_IN: Set lines to input mode +* @GPIOD_OUT_LOW: Set lines to output and drive them low +* @GPIOD_OUT_HIGH: Set lines to output and drive them high +* @GPIOD_OUT_LOW_OPEN_DRAIN: Set lines to open-drain output and drive them low +* @GPIOD_OUT_HIGH_OPEN_DRAIN: Set lines to open-drain output and drive them high */ enum gpiod_flags {GPIOD_ASIS =0 ,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 493/731 gpiolib: protect the GPIO device against being dropped while in use by user-space
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit bdbbae241a04f387ba910b8609f95fad5f1470c7 ]
While any of the GPIO cdev syscalls is in progress, the kernel can call gpiochip_remove() (for instance, when a USB GPIO expander is disconnected) which will set gdev->chip to NULL after which any subsequent access will cause a crash.
To avoid that: use an RW-semaphore in which the syscalls take it for reading (so that we don't needlessly prohibit the user-space from calling syscalls simultaneously) while gpiochip_remove() takes it for writing so that it can only happen once all syscalls return.
--- drivers/gpio/gpiolib-cdev.c | 177 +++++++++++++++++++++++++++++++----- drivers/gpio/gpiolib.c | 4 + drivers/gpio/gpiolib.h | 5 + 3 files changed, 161 insertions(+), 25 deletions(-)
drivers/gpio/gpiolib-cdev.c +152 -25
@@ -54,6 +54,50 @@ static_assert(IS_ALIGNED(sizeof(struct gpio_v2_line_values), 8));* interface to gpiolib GPIOs via ioctl()s. */ +typedef __poll_t (*poll_fn )(struct file *,struct poll_table_struct *); +typedef long (*ioctl_fn )(struct file *,unsigned int ,unsigned long ); +typedef ssize_t (*read_fn )(struct file *,char __user *, +size_t count,loff_t *); + +static __poll_t call_poll_locked (struct file *file, +struct poll_table_struct *wait, +struct gpio_device *gdev,poll_fn func) +{ +__poll_t ret; + +down_read (&gdev->sem); + ret =func (file, wait); +up_read (&gdev->sem); + +return ret; +} + +static long call_ioctl_locked (struct file *file,unsigned int cmd, +unsigned long arg,struct gpio_device *gdev, +ioctl_fn func) +{ +long ret; + +down_read (&gdev->sem); + ret =func (file, cmd, arg); +up_read (&gdev->sem); + +return ret; +} + +static ssize_t call_read_locked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps, +struct gpio_device *gdev,read_fn func) +{ +ssize_t ret; + +down_read (&gdev->sem); + ret =func (file, buf, count, f_ps); +up_read (&gdev->sem); + +return ret; +} +/* * GPIO line handle management */
@@ -190,8 +234,8 @@ static long linehandle_set_config(struct linehandle_state *lh,return 0 ; } -static long linehandle_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long linehandle_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct linehandle_state *lh = file->private_data;void __user *ip = (void __user *)arg;
@@ -249,6 +293,15 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd, } } +static long linehandle_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct linehandle_state *lh = file->private_data; + +return call_ioctl_locked (file, cmd, arg, lh->gdev, + linehandle_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long linehandle_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -1185,8 +1238,8 @@ static long linereq_set_config(struct linereq *lr, void __user *ip)return ret; } -static long linereq_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long linereq_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct linereq *lr = file->private_data;void __user *ip = (void __user *)arg;
@@ -1206,6 +1259,15 @@ static long linereq_ioctl(struct file *file, unsigned int cmd, } } +static long linereq_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct linereq *lr = file->private_data; + +return call_ioctl_locked (file, cmd, arg, lr->gdev, + linereq_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long linereq_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -1214,8 +1276,8 @@ static long linereq_ioctl_compat(struct file *file, unsigned int cmd, }#endif -static __poll_t linereq_poll (struct file *file, -struct poll_table_struct *wait) +static __poll_t linereq_poll_unlocked (struct file *file, +struct poll_table_struct *wait) {struct linereq *lr = file->private_data;__poll_t events =0 ;
@@ -1232,10 +1294,16 @@ static __poll_t linereq_poll(struct file *file,return events; } -static ssize_t linereq_read (struct file *file, -char __user *buf, -size_t count, -loff_t *f_ps) +static __poll_t linereq_poll (struct file *file, +struct poll_table_struct *wait) +{ +struct linereq *lr = file->private_data; + +return call_poll_locked (file, wait, lr->gdev, linereq_poll_unlocked); +} + +static ssize_t linereq_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) {struct linereq *lr = file->private_data;struct gpio_v2_line_event le;
@@ -1289,6 +1357,15 @@ static ssize_t linereq_read(struct file *file,return bytes_read; } +static ssize_t linereq_read (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) +{ +struct linereq *lr = file->private_data; + +return call_read_locked (file, buf, count, f_ps, lr->gdev, + linereq_read_unlocked); +} +static void linereq_free (struct linereq *lr) {unsigned int i;
@@ -1504,8 +1581,8 @@ struct lineevent_state { (GPIOEVENT_REQUEST_RISING_EDGE | \ GPIOEVENT_REQUEST_FALLING_EDGE) -static __poll_t lineevent_poll (struct file *file, -struct poll_table_struct *wait) +static __poll_t lineevent_poll_unlocked (struct file *file, +struct poll_table_struct *wait) {struct lineevent_state *le = file->private_data;__poll_t events =0 ;
@@ -1521,15 +1598,21 @@ static __poll_t lineevent_poll(struct file *file,return events; } +static __poll_t lineevent_poll (struct file *file, +struct poll_table_struct *wait) +{ +struct lineevent_state *le = file->private_data; + +return call_poll_locked (file, wait, le->gdev, lineevent_poll_unlocked); +} +struct compat_gpioeevent_data {compat_u64 timestamp;u32 id; }; -static ssize_t lineevent_read (struct file *file, -char __user *buf, -size_t count, -loff_t *f_ps) +static ssize_t lineevent_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) {struct lineevent_state *le = file->private_data;struct gpioevent_data ge;
@@ -1597,6 +1680,15 @@ static ssize_t lineevent_read(struct file *file,return bytes_read; } +static ssize_t lineevent_read (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) +{ +struct lineevent_state *le = file->private_data; + +return call_read_locked (file, buf, count, f_ps, le->gdev, + lineevent_read_unlocked); +} +static void lineevent_free (struct lineevent_state *le) {if (le->irq)
@@ -1614,8 +1706,8 @@ static int lineevent_release(struct inode *inode, struct file *file)return 0 ; } -static long lineevent_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long lineevent_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct lineevent_state *le = file->private_data;void __user *ip = (void __user *)arg;
@@ -1646,6 +1738,15 @@ static long lineevent_ioctl(struct file *file, unsigned int cmd,return -EINVAL ; } +static long lineevent_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct lineevent_state *le = file->private_data; + +return call_ioctl_locked (file, cmd, arg, le->gdev, + lineevent_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long lineevent_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -2202,8 +2303,8 @@ static int lineinfo_changed_notify(struct notifier_block *nb,return NOTIFY_OK ; } -static __poll_t lineinfo_watch_poll (struct file *file, -struct poll_table_struct *pollt) +static __poll_t lineinfo_watch_poll_unlocked (struct file *file, +struct poll_table_struct *pollt) {struct gpio_chardev_data *cdev = file->private_data;__poll_t events =0 ;
@@ -2220,8 +2321,17 @@ static __poll_t lineinfo_watch_poll(struct file *file,return events; } -static ssize_t lineinfo_watch_read (struct file *file,char __user *buf, -size_t count,loff_t *off) +static __poll_t lineinfo_watch_poll (struct file *file, +struct poll_table_struct *pollt) +{ +struct gpio_chardev_data *cdev = file->private_data; + +return call_poll_locked (file, pollt, cdev->gdev, + lineinfo_watch_poll_unlocked); +} + +static ssize_t lineinfo_watch_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *off) {struct gpio_chardev_data *cdev = file->private_data;struct gpio_v2_line_info_changed event;
@@ -2299,6 +2409,15 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,return bytes_read; } +static ssize_t lineinfo_watch_read (struct file *file,char __user *buf, +size_t count,loff_t *off) +{ +struct gpio_chardev_data *cdev = file->private_data; + +return call_read_locked (file, buf, count, off, cdev->gdev, + lineinfo_watch_read_unlocked); +} +/** * gpio_chrdev_open() - open the chardev for ioctl operations * @inode: inode for this chardev
@@ -2312,13 +2431,17 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)struct gpio_chardev_data *cdev;int ret = -ENOMEM ; +down_read (&gdev->sem); +/* Fail on open if the backing gpiochip is gone */ -if (!gdev->chip) -return -ENODEV ; +if (!gdev->chip) { + ret = -ENODEV ; + goto out_unlock; + } cdev =kzalloc (sizeof (*cdev),GFP_KERNEL );if (!cdev) -return -ENOMEM ; + goto out_unlock; cdev->watched_lines =bitmap_zalloc (gdev->chip->ngpio,GFP_KERNEL );if (!cdev->watched_lines)
@@ -2341,6 +2464,8 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)if (ret) goto out_unregister_notifier; +up_read (&gdev->sem); +return ret; out_unregister_notifier:
@@ -2350,6 +2475,8 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)bitmap_free (cdev->watched_lines); out_free_cdev:kfree (cdev); +out_unlock: +up_read (&gdev->sem);return ret; }
drivers/gpio/gpiolib.c +4 -0
@@ -727,6 +727,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,spin_unlock_irqrestore (&gpio_lock, flags);BLOCKING_INIT_NOTIFIER_HEAD (&gdev->notifier); +init_rwsem (&gdev->sem);#ifdef CONFIG_PINCTRL INIT_LIST_HEAD (&gdev->pin_ranges);
@@ -865,6 +866,8 @@ void gpiochip_remove(struct gpio_chip *gc)unsigned long flags;unsigned int i; +down_write (&gdev->sem); +/* FIXME: should the legacy sysfs handling be moved to gpio_device? */ gpiochip_sysfs_unregister (gdev);gpiochip_free_hogs (gc);
@@ -899,6 +902,7 @@ void gpiochip_remove(struct gpio_chip *gc)* gone. */ gcdev_unregister (gdev); +up_write (&gdev->sem);put_device (&gdev->dev); }EXPORT_SYMBOL_GPL (gpiochip_remove);
drivers/gpio/gpiolib.h +5 -0
@@ -15,6 +15,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/cdev.h> +#include <linux/rwsem.h> #define GPIOCHIP_NAME "gpiochip"
@@ -39,6 +40,9 @@* @list: links gpio_device:s together for traversal * @notifier: used to notify subscribers about lines being requested, released * or reconfigured +* @sem: protects the structure from a NULL-pointer dereference of @chip by +* user-space operations when the device gets unregistered during +* a hot-unplug event * @pin_ranges: range of pins served by the GPIO driver * * This state container holds most of the runtime variable data
@@ -60,6 +64,7 @@ struct gpio_device {void *data;struct list_head list;struct blocking_notifier_head notifier; +struct rw_semaphore sem;#ifdef CONFIG_PINCTRL /*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 494/731 i2c: mux: reg: check return value after calling platform_get_resource()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 2d47b79d2bd39cc6369eccf94a06568d84c906ae ]
It will cause null-ptr-deref in resource_size(), if platform_get_resource() returns NULL, move calling resource_size() after devm_ioremap_resource() that will check 'res' to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.
--- drivers/i2c/muxes/i2c-mux-reg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/i2c/muxes/i2c-mux-reg.c +2 -3
@@ -183,13 +183,12 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)if (!mux->data.reg) {dev_info (&pdev->dev,"Register not set, using platform resource\n" ); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mux->data.reg_size =resource_size (res); - mux->data.reg =devm_ioremap_resource (&pdev->dev, res); + mux->data.reg =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (mux->data.reg)) { ret =PTR_ERR (mux->data.reg); goto err_put_parent; } + mux->data.reg_size =resource_size (res); } if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 495/731 i2c: ismt: Fix an out-of-bounds bug in ismt_access()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 39244cc754829bf707dccd12e2ce37510f5b1f8d ]
When the driver does not check the data from the user, the variable 'data->block[0]' may be very large to cause an out-of-bounds bug.
The following log can reveal it:
[ 33.995542] i2c i2c-1: ioctl, cmd=0x720, arg=0x7ffcb3dc3a20 [ 33.995978] ismt_smbus 0000:00:05.0: I2C_SMBUS_BLOCK_DATA: WRITE [ 33.996475] ================================================================== [ 33.996995] BUG: KASAN: out-of-bounds in ismt_access.cold+0x374/0x214b [ 33.997473] Read of size 18446744073709551615 at addr ffff88810efcfdb1 by task ismt_poc/485 [ 33.999450] Call Trace: [ 34.001849] memcpy+0x20/0x60 [ 34.002077] ismt_access.cold+0x374/0x214b [ 34.003382] __i2c_smbus_xfer+0x44f/0xfb0 [ 34.004007] i2c_smbus_xfer+0x10a/0x390 [ 34.004291] i2cdev_ioctl_smbus+0x2c8/0x710 [ 34.005196] i2cdev_ioctl+0x5ec/0x74c
Fix this bug by checking the size of 'data->block[0]' first.
--- drivers/i2c/busses/i2c-ismt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-ismt.c +3 -0
@@ -509,6 +509,9 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,if (read_write ==I2C_SMBUS_WRITE ) {/* Block Write */ dev_dbg (dev,"I2C_SMBUS_BLOCK_DATA: WRITE\n" ); +if (data->block[0 ] <1 || data->block[0 ] >I2C_SMBUS_BLOCK_MAX ) +return -EINVAL ; + dma_size = data->block[0 ] +1 ; dma_direction =DMA_TO_DEVICE ; desc->wr_len_cmd = dma_size;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 496/731 usb: storage: Add check for kcalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit c35ca10f53c51eeb610d3f8fbc6dd6d511b58a58 ]
As kcalloc may return NULL pointer, the return value should be checked and return error if fails as same as the ones in alauda_read_map.
--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/storage/alauda.c +2 -0
@@ -438,6 +438,8 @@ static int alauda_init_media(struct us_data *us) + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift);MEDIA_INFO (us).pba_to_lba =kcalloc (num_zones,sizeof (u16 *),GFP_NOIO );MEDIA_INFO (us).lba_to_pba =kcalloc (num_zones,sizeof (u16 *),GFP_NOIO ); +if (MEDIA_INFO (us).pba_to_lba ==NULL ||MEDIA_INFO (us).lba_to_pba ==NULL ) +return USB_STOR_TRANSPORT_ERROR ;if (alauda_reset_media (us) !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 497/731 tracing/hist: Fix issue of losting command info in error_log
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
[ Upstream commit 608c6ed3337850c767ab0dd6c583477922233e29 ]
When input some constructed invalid 'trigger' command, command info in 'error_log' are lost [1].
The root cause is that there is a path that event_hist_trigger_parse() is recursely called once and 'last_cmd' which save origin command is cleared, then later calling of hist_err() will no longer record origin command info:
event_hist_trigger_parse() {
last_cmd_set() // <1> 'last_cmd' save origin command here at first
create_actions() {
onmatch_create() {
action_create() {
trace_action_create() {
trace_action_create_field_var() {
create_field_var_hist() {
event_hist_trigger_parse() { // <2> recursely called once
hist_err_clear() // <3> 'last_cmd' is cleared here
}
hist_err() // <4> No longer find origin command!!!Since 'glob' is empty string while running into the recurse call, we can trickly check it and bypass the call of hist_err_clear() to solve it.
[1]
# cd /sys/kernel/tracing
# echo "my_synth_event int v1; int v2; int v3;" >> synthetic_events
# echo 'hist:keys=pid' >> events/sched/sched_waking/trigger
# echo "hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(\
pid,pid1)" >> events/sched/sched_switch/trigger
# cat error_log
[ 8.405018] hist:sched:sched_switch: error: Couldn't find synthetic event
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.816902] hist:sched:sched_switch: error: Couldn't find field
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.816902] hist:sched:sched_switch: error: Couldn't parse field variable
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.999880] : error: Couldn't find field
Command:
^
[ 8.999880] : error: Couldn't parse field variable
Command:
^
[ 8.999880] : error: Couldn't find field
Command:
^
[ 8.999880] : error: Couldn't create histogram for field
Command:
^--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -5954,7 +5954,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,/* Just return zero, not the number of registered triggers */ ret =0 ; out: -if (ret ==0 ) +if (ret ==0 && glob[0 ])hist_err_clear ();return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 498/731 ksmbd: Fix resource leak in ksmbd_session_rpc_open()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit bc044414fa0326a4e5c3c509c00b1fcaf621b5f4 ]
When ksmbd_rpc_open() fails then it must call ksmbd_rpc_id_free() to undo the result of ksmbd_ipc_id_alloc().
--- fs/ksmbd/mgmt/user_session.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ksmbd/mgmt/user_session.c +5 -3
@@ -106,15 +106,17 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) entry->method = method; entry->id =ksmbd_ipc_id_alloc ();if (entry->id <0 ) - goto error; + goto free_entry; resp =ksmbd_rpc_open (sess, entry->id);if (!resp) - goto error; + goto free_id;kvfree (resp);return entry->id; -error: +free_id: +ksmbd_rpc_id_free (entry->id); +free_entry:list_del (&entry->list);kfree (entry);return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 499/731 samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit d1f0f50fbbbbca1e3e8157e51934613bf88f6d44 ]
Add missing pci_disable_device() in fail path of mdpy_fb_probe(). Besides, fix missing release functions in mdpy_fb_remove().
--- samples/vfio-mdev/mdpy-fb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
samples/vfio-mdev/mdpy-fb.c +7 -1
@@ -109,7 +109,7 @@ static int mdpy_fb_probe(struct pci_dev *pdev, ret =pci_request_regions (pdev,"mdpy-fb" );if (ret <0 ) -return ret; + goto err_disable_dev;pci_read_config_dword (pdev,MDPY_FORMAT_OFFSET , &format);pci_read_config_dword (pdev,MDPY_WIDTH_OFFSET , &width);
@@ -191,6 +191,9 @@ static int mdpy_fb_probe(struct pci_dev *pdev, err_release_regions:pci_release_regions (pdev); +err_disable_dev: +pci_disable_device (pdev); +return ret; }
@@ -199,7 +202,10 @@ static void mdpy_fb_remove(struct pci_dev *pdev)struct fb_info *info =pci_get_drvdata (pdev);unregister_framebuffer (info); +iounmap (info->screen_base);framebuffer_release (info); +pci_release_regions (pdev); +pci_disable_device (pdev); }static struct pci_device_id mdpy_fb_pci_table[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 500/731 thermal/drivers/imx8mm_thermal: Validate temperature range
In reply to Greg Kroah-HartmanFrom: Marcus Folkesson <[email protected]>
[ Upstream commit d37edc7370273306d8747097fafa62436c1cfe16 ]
Check against the upper temperature limit (125 degrees C) before consider the temperature valid.
--- drivers/thermal/imx8mm_thermal.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/thermal/imx8mm_thermal.c +7 -1
@@ -65,8 +65,14 @@ static int imx8mm_tmu_get_temp(void *data, int *temp)u32 val; val =readl_relaxed (tmu->base +TRITSR ) &TRITSR_TEMP0_VAL_MASK ; + +/* +* Do not validate against the V bit (bit 31) due to errata +* ERR051272: TMU: Bit 31 of registers TMU_TSCR/TMU_TRITSR/TMU_TRATSR invalid +*/ + *temp = val *1000 ; -if (*temp <VER1_TEMP_LOW_LIMIT ) +if (*temp <VER1_TEMP_LOW_LIMIT || *temp >VER2_TEMP_HIGH_LIMIT )return -EAGAIN ;return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 501/731 thermal/drivers/qcom/temp-alarm: Fix inaccurate warning for gen2
In reply to Greg Kroah-HartmanFrom: Luca Weiss <[email protected]>
[ Upstream commit 8763f8acbf8aef22a2321d4c978cd078aa3b8f64 ]
On gen2 chips the stage2 threshold is not 140 degC but 125 degC.
Make the warning message clearer by using this variable and also by including the temperature that was checked for.
--- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/qcom/qcom-spmi-temp-alarm.c +2 -1
@@ -251,7 +251,8 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip, disable_s2_shutdown = true; else dev_warn(chip->dev, - "No ADC is configured and critical temperature is above the maximum stage 2 threshold of 140 C! Configuring stage 2 shutdown at 140 C.\n"); +"No ADC is configured and critical temperature %d mC is above the maximum stage 2 threshold of %ld mC! Configuring stage 2 shutdown at %ld mC.\n" , + temp, stage2_threshold_max, stage2_threshold_max); } skip:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 502/731 thermal/drivers/qcom/lmh: Fix irq handler return value
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit 46a891e45be97c6781ac34f5ec777d69370e252b ]
After enough invocations the LMh irq is eventually reported as bad, because the handler doesn't return IRQ_HANDLED, fix this.
--- drivers/thermal/qcom/lmh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/lmh.c +1 -1
@@ -43,7 +43,7 @@ static irqreturn_t lmh_handle_irq(int hw_irq, void *data)if (irq)generic_handle_irq (irq); -return 0 ; +return IRQ_HANDLED ; }static void lmh_enable_interrupt (struct irq_data *d)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 503/731 fbdev: ssd1307fb: Drop optional dependency
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 025e3b507a3a8e1ee96a3112bb67495c77d6cdb6 ]
Only a single out of three devices need a PWM, so from driver it's optional. Moreover it's a single driver in the entire kernel that currently selects PWM. Unfortunately this selection is a root cause of the circular dependencies when we want to enable optional PWM for some other drivers that select GPIOLIB.
--- drivers/video/fbdev/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/video/fbdev/Kconfig +0 -1
@@ -2218,7 +2218,6 @@ config FB_SSD1307 select FB_SYS_COPYAREA select FB_SYS_IMAGEBLIT select FB_DEFERRED_IO - select PWM select FB_BACKLIGHT help This driver implements support for the Solomon SSD1307
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 504/731 fbdev: pm2fb: fix missing pci_disable_device()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ed359a464846b48f76ea6cc5cd8257e545ac97f4 ]
Add missing pci_disable_device() in error path of probe() and remove() path.
--- drivers/video/fbdev/pm2fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/video/fbdev/pm2fb.c +7 -2
@@ -1530,8 +1530,10 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) } info =framebuffer_alloc (sizeof (struct pm2fb_par ), &pdev->dev); -if (!info) -return -ENOMEM ; +if (!info) { + err = -ENOMEM ; + goto err_exit_disable; + } default_par = info->par;switch (pdev->device) {
@@ -1712,6 +1714,8 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id)release_mem_region (pm2fb_fix.mmio_start, pm2fb_fix.mmio_len); err_exit_neither:framebuffer_release (info); + err_exit_disable: +pci_disable_device (pdev);return retval; }
@@ -1738,6 +1742,7 @@ static void pm2fb_remove(struct pci_dev *pdev)fb_dealloc_cmap (&info->cmap);kfree (info->pixmap.addr);framebuffer_release (info); +pci_disable_device (pdev); }static const struct pci_device_id pm2fb_id_table[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 505/731 fbdev: via: Fix error in via_core_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 5886b130de953cfb8826f7771ec8640a79934a7f ]
via_core_init() won't exit the driver when pci_register_driver() failed. Exit the viafb-i2c and the viafb-gpio in failed path to prevent error.
VIA Graphics Integration Chipset framebuffer 2.4 initializing
Error: Driver 'viafb-i2c' is already registered, aborting...
Error: Driver 'viafb-gpio' is already registered, aborting...
--- drivers/video/fbdev/via/via-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/video/fbdev/via/via-core.c +8 -1
@@ -725,7 +725,14 @@ static int __init via_core_init(void)return ret;viafb_i2c_init ();viafb_gpio_init (); -return pci_register_driver (&via_driver); + ret =pci_register_driver (&via_driver); +if (ret) { +viafb_gpio_exit (); +viafb_i2c_exit (); +return ret; + } + +return 0 ; } static void __exit via_core_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 506/731 fbdev: vermilion: decrease reference count in error path
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 001f2cdb952a9566c77fb4b5470cc361db5601bb ]
pci_get_device() will increase the reference count for the returned pci_dev. For the error path, we need to use pci_dev_put() to decrease the reference count.
--- drivers/video/fbdev/vermilion/vermilion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/vermilion/vermilion.c +3 -1
@@ -277,8 +277,10 @@ static int vmlfb_get_gpu(struct vml_par *par)mutex_unlock (&vml_mutex); -if (pci_enable_device (par->gpu) <0 ) +if (pci_enable_device (par->gpu) <0 ) { +pci_dev_put (par->gpu);return -ENODEV ; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 507/731 fbdev: ep93xx-fb: Add missing clk_disable_unprepare in ep93xxfb_probe()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit c84bf485a5aaf9aa0764a58832b7ef4375c29f03 ]
The clk_disable_unprepare() should be called in the error handling of register_framebuffer(), fix it.
--- drivers/video/fbdev/ep93xx-fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/ep93xx-fb.c +3 -1
@@ -552,12 +552,14 @@ static int ep93xxfb_probe(struct platform_device *pdev) err =register_framebuffer (info);if (err) - goto failed_check; + goto failed_framebuffer;dev_info (info->dev,"registered. Mode = %dx%d-%d\n" , info->var.xres, info->var.yres, info->var.bits_per_pixel);return 0 ; +failed_framebuffer: +clk_disable_unprepare (fbi->clk); failed_check:if (fbi->mach_info->teardown) fbi->mach_info->teardown (pdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 508/731 fbdev: geode: dont build on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 71c53e19226b0166ba387d3c590d0509f541a0a1 ]
The geode fbdev driver uses struct cpuinfo fields that are not present on ARCH=um, so don't allow this driver to be built on UML.
Prevents these build errors:
In file included from ../arch/x86/include/asm/olpc.h:7:0,
from ../drivers/mfd/cs5535-mfd.c:17:
../arch/x86/include/asm/geode.h: In function ‘is_geode_gx’:../arch/x86/include/asm/geode.h:16:24: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:16:39: error: ‘X86_VENDOR_NSC’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:17:17: error: ‘struct cpuinfo_um’ has no member named ‘x86’
(boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:18:17: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
(boot_cpu_data.x86_model == 5));../arch/x86/include/asm/geode.h: In function ‘is_geode_lx’:../arch/x86/include/asm/geode.h:23:24: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:23:39: error: ‘X86_VENDOR_AMD’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:24:17: error: ‘struct cpuinfo_um’ has no member named ‘x86’
(boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:25:17: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
(boot_cpu_data.x86_model == 10));
--- drivers/video/fbdev/geode/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/geode/Kconfig +1 -0
@@ -5,6 +5,7 @@ config FB_GEODE bool "AMD Geode family framebuffer support" depends on FB && PCI && (X86_32 || (X86 && COMPILE_TEST)) + depends on !UML help Say 'Y' here to allow you to select framebuffer drivers for the AMD Geode family of processors.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 509/731 fbdev: uvesafb: dont build on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 35b4f4d4a725cf8f8c10649163cd12aed509b953 ]
The uvesafb fbdev driver uses memory management information that is not available on ARCH=um, so don't allow this driver to be built on UML.
Prevents these build errors:
../drivers/video/fbdev/uvesafb.c: In function ‘uvesafb_vbe_init’:../drivers/video/fbdev/uvesafb.c:807:21: error: ‘__supported_pte_mask’ undeclared (first use in this function)
807 | if (__supported_pte_mask & _PAGE_NX) {../drivers/video/fbdev/uvesafb.c:807:44: error: ‘_PAGE_NX’ undeclared (first use in this function)
807 | if (__supported_pte_mask & _PAGE_NX) {
--- drivers/video/fbdev/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/Kconfig +1 -0
@@ -606,6 +606,7 @@ config FB_TGA config FB_UVESA tristate "Userspace VESA VGA graphics support" depends on FB && CONNECTOR + depends on !UML select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 510/731 fbdev: uvesafb: Fixes an error handling path in uvesafb_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit a94371040712031ba129c7e9d8ff04a06a2f8207 ]
If an error occurs after a successful uvesafb_init_mtrr() call, it must be undone by a corresponding arch_phys_wc_del() call, as already done in the remove function.
This has been added in the remove function in commit 63e28a7a5ffc ("uvesafb: Clean up MTRR code")
--- drivers/video/fbdev/uvesafb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/uvesafb.c +1 -0
@@ -1758,6 +1758,7 @@ static int uvesafb_probe(struct platform_device *dev) out_unmap:iounmap (info->screen_base); out_mem: +arch_phys_wc_del (par->mtrr_handle);release_mem_region (info->fix.smem_start, info->fix.smem_len); out_reg:release_region (0x3c0 ,32 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 511/731 HSI: omap_ssi_core: fix unbalanced pm_runtime_disable()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f5181c35ed7ba0ceb6e42872aad1334d994b0175 ]
In error label 'out1' path in ssi_probe(), the pm_runtime_enable() has not been called yet, so pm_runtime_disable() is not needed.
--- drivers/hsi/controllers/omap_ssi_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +1 -1
@@ -536,9 +536,9 @@ static int ssi_probe(struct platform_device *pd)device_for_each_child (&pd->dev,NULL , ssi_remove_ports); out2:ssi_remove_controller (ssi); +pm_runtime_disable (&pd->dev); out1:platform_set_drvdata (pd,NULL ); -pm_runtime_disable (&pd->dev);return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 512/731 HSI: omap_ssi_core: fix possible memory leak in ssi_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 1aff514e1d2bd47854dbbdf867970b9d463d4c57 ]
If ssi_add_controller() returns error, it should call hsi_put_controller() to give up the reference that was set in hsi_alloc_controller(), so that it can call hsi_controller_release() to free controller and ports that allocated in hsi_alloc_controller().
--- drivers/hsi/controllers/omap_ssi_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +3 -1
@@ -502,8 +502,10 @@ static int ssi_probe(struct platform_device *pd)platform_set_drvdata (pd, ssi); err =ssi_add_controller (ssi, pd); -if (err <0 ) +if (err <0 ) { +hsi_put_controller (ssi); goto out1; + }pm_runtime_enable (&pd->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 513/731 power: supply: fix residue sysfs file in error handle route of __power_supply_register()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit 5b79480ce1978864ac3f06f2134dfa3b6691fe74 ]
If device_add() succeeds, we should call device_del() when want to get rid of it, so move it into proper jump symbol.
Otherwise, when __power_supply_register() returns fail and goto wakeup_init_failed to exit, there is still residue device file in sysfs. When attempt to probe device again, sysfs would complain as below:
sysfs: cannot create duplicate filename '/devices/platform/i2c/i2c-0/0-001c/power_supply/adp5061'
Call Trace: dump_stack_lvl+0x68/0x85 sysfs_warn_dup.cold+0x1c/0x29 sysfs_create_dir_ns+0x1b1/0x1d0 kobject_add_internal+0x143/0x390 kobject_add+0x108/0x170
--- drivers/power/supply/power_supply_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/power_supply_core.c +1 -1
@@ -1220,8 +1220,8 @@ __power_supply_register(struct device *parent, register_cooler_failed:psy_unregister_thermal (psy); register_thermal_failed: -device_del (dev); wakeup_init_failed: +device_del (dev); device_add_failed: check_supplies_failed: dev_set_name_failed:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 514/731 perf trace: Return error if a system call doesnt exist
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit d4223e1776c30b2ce8d0e6eaadcbf696e60fca3c ]
When a system call is not detected, the reason is either because the system call ID is out of scope or failure to find the corresponding path in the sysfs, trace__read_syscall_info() returns zero. Finally, without returning an error value it introduces confusion for the caller.
This patch lets the function trace__read_syscall_info() to return -EEXIST when a system call doesn't exist.
--- tools/perf/builtin-trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +2 -2
@@ -1782,11 +1782,11 @@ static int trace__read_syscall_info(struct trace *trace, int id)#endif sc = trace->syscalls.table + id;if (sc->nonexistent) -return 0 ; +return -EEXIST ;if (name ==NULL ) { sc->nonexistent = true; -return 0 ; +return -EEXIST ; } sc->name = name;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 515/731 perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit eadcab4c7a66e1df03d32da0db55d89fd9343fcc ]
This patch defines a macro RAW_SYSCALL_ARGS_NUM to replace the open coded number '6'.
Stable-dep-of: 03e9a5d8eb55 ("perf trace: Handle failure when trace point folder is missed")
--- tools/perf/builtin-trace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/builtin-trace.c +7 -4
@@ -87,6 +87,8 @@# define F_LINUX_SPECIFIC_BASE 1024#endif +#define RAW_SYSCALL_ARGS_NUM 6 +/* * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100 */
@@ -107,7 +109,7 @@ struct syscall_fmt {const char *sys_enter, *sys_exit; } bpf_prog_name; -struct syscall_arg_fmt arg[6 ]; +struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM ];u8 nr_args;bool errpid;bool timeout;
@@ -1224,7 +1226,7 @@ struct syscall {*/ struct bpf_map_syscall_entry {bool enabled; -u16 string_args_len[6 ]; +u16 string_args_len[RAW_SYSCALL_ARGS_NUM ]; };/*
@@ -1649,7 +1651,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args) {int idx; -if (nr_args ==6 && sc->fmt && sc->fmt->nr_args !=0 ) +if (nr_args ==RAW_SYSCALL_ARGS_NUM && sc->fmt && sc->fmt->nr_args !=0 ) nr_args = sc->fmt->nr_args; sc->arg_fmt =calloc (nr_args,sizeof (*sc->arg_fmt));
@@ -1800,7 +1802,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format =trace_event__tp_format ("syscalls" , tp_name); } -if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ?6 : sc->tp_format->format.nr_fields)) +if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ? +RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields))return -ENOMEM ;if (IS_ERR (sc->tp_format))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 516/731 perf trace: Handle failure when trace point folder is missed
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit 03e9a5d8eb552a1bf692a9c8a5ecd50f4e428006 ]
On Arm64 a case is perf tools fails to find the corresponding trace point folder for system calls listed in the table 'syscalltbl_arm64', e.g. the generated system call table contains "lookup_dcookie" but we cannot find out the matched trace point folder for it.
We need to figure out if there have any issue for the generated system call table, on the other hand, we need to handle the case when trace point folder is missed under sysfs, this patch sets the flag syscall::nonexistent as true and returns the error from trace__read_syscall_info().
Another problem is for trace__syscall_info(), it returns two different values if a system call doesn't exist: at the first time calling trace__syscall_info() it returns NULL when the system call doesn't exist, later if call trace__syscall_info() again for the same missed system call, it returns pointer of syscall. trace__syscall_info() checks the condition 'syscalls.table[id].name == NULL', but the name will be assigned in the first invoking even the system call is not found.
So checking system call's name in trace__syscall_info() is not the right thing to do, this patch simply checks flag syscall::nonexistent to make decision if a system call exists or not, finally trace__syscall_info() returns the consistent result (NULL) if a system call doesn't existed.
--- tools/perf/builtin-trace.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
tools/perf/builtin-trace.c +10 -7
@@ -1802,13 +1802,19 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format =trace_event__tp_format ("syscalls" , tp_name); } +/* +* Fails to read trace point format via sysfs node, so the trace point +* doesn't exist. Set the 'nonexistent' flag as true. +*/ +if (IS_ERR (sc->tp_format)) { + sc->nonexistent = true; +return PTR_ERR (sc->tp_format); + } +if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ?RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields))return -ENOMEM ; -if (IS_ERR (sc->tp_format)) -return PTR_ERR (sc->tp_format); - sc->args = sc->tp_format->format.fields;/* * We need to check and discard the first variable '__syscall_nr'
@@ -2125,11 +2131,8 @@ static struct syscall *trace__syscall_info(struct trace *trace, (err = trace__read_syscall_info(trace, id)) != 0) goto out_cant_read; -if (trace->syscalls.table[id].name ==NULL ) { -if (trace->syscalls.table[id].nonexistent) -return NULL ; +if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) goto out_cant_read; - }return &trace->syscalls.table[id];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 517/731 perf symbol: correction while adjusting symbol
In reply to Greg Kroah-HartmanFrom: Ajay Kaher <[email protected]>
[ Upstream commit 6f520ce17920b3cdfbd2479b3ccf27f9706219d0 ]
perf doesn't provide proper symbol information for specially crafted .debug files.
Sometimes .debug file may not have similar program header as runtime ELF file. For example if we generate .debug file using objcopy --only-keep-debug resulting file will not contain .text, .data and other runtime sections. That means corresponding program headers will have zero FileSiz and modified Offset.
Example: program header of text section of libxxx.so:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x00000000003d3000 0x00000000003d3000 0x00000000003d3000
0x000000000055ae80 0x000000000055ae80 R E 0x1000
Same program header after executing:
objcopy --only-keep-debug libxxx.so libxxx.so.debug
LOAD 0x0000000000001000 0x00000000003d3000 0x00000000003d3000
0x0000000000000000 0x000000000055ae80 R E 0x1000
Offset and FileSiz have been changed.
Following formula will not provide correct value, if program header taken from .debug file (syms_ss):
sym.st_value -= phdr.p_vaddr - phdr.p_offset;
Correct program header information is located inside runtime ELF file (runtime_ss).
--- tools/perf/util/symbol-elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +1 -1
@@ -1292,7 +1292,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, (!used_opd && syms_ss->adjust_symbols)) {GElf_Phdr phdr; -if (elf_read_program_header (syms_ss->elf, +if (elf_read_program_header (runtime_ss->elf, (u64 )sym.st_value, &phdr)) { pr_debug4("%s: failed to find program header for " "symbol: %s st_value: %#" PRIx64 "\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 518/731 power: supply: z2_battery: Fix possible memleak in z2_batt_probe()
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 955bee204f3dd307642c101b75e370662987e735 ]
If devm_gpiod_get_optional() returns error, the charger should be freed before z2_batt_probe returns according to the context. We fix it by just gotoing to 'err' branch.
--- drivers/power/supply/z2_battery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/z2_battery.c +4 -2
@@ -206,10 +206,12 @@ static int z2_batt_probe(struct i2c_client *client, charger->charge_gpiod =devm_gpiod_get_optional (&client->dev,NULL ,GPIOD_IN ); -if (IS_ERR (charger->charge_gpiod)) -return dev_err_probe (&client->dev, +if (IS_ERR (charger->charge_gpiod)) { + ret =dev_err_probe (&client->dev,PTR_ERR (charger->charge_gpiod),"failed to get charge GPIO\n" ); + goto err; + }if (charger->charge_gpiod) {gpiod_set_consumer_name (charger->charge_gpiod,"BATT CHRG" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 519/731 HSI: omap_ssi_core: Fix error handling in ssi_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 3ffa9f713c39a213a08d9ff13ab983a8aa5d8b5d ]
The ssi_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the ssi_pdriver is not unregistered.
Fix by unregister ssi_pdriver when the last platform_driver_register() failed.
--- drivers/hsi/controllers/omap_ssi_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +7 -1
@@ -631,7 +631,13 @@ static int __init ssi_init(void) {if (ret)return ret; -return platform_driver_register (&ssi_port_pdriver); + ret =platform_driver_register (&ssi_port_pdriver); +if (ret) { +platform_driver_unregister (&ssi_pdriver); +return ret; + } + +return 0 ; }module_init (ssi_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 520/731 power: supply: ab8500: Fix error handling in ab8500_charger_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit c4d33381b134da188ccd1084aef21e2b8c3c422e ]
The ab8500_charger_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, all ab8500_charger_component_drivers are not unregistered.
Fix by unregister ab8500_charger_component_drivers when platform_driver_register() failed.
--- drivers/power/supply/ab8500_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/supply/ab8500_charger.c +8 -1
@@ -3726,7 +3726,14 @@ static int __init ab8500_charger_init(void)if (ret)return ret; -return platform_driver_register (&ab8500_charger_driver); + ret =platform_driver_register (&ab8500_charger_driver); +if (ret) { +platform_unregister_drivers (ab8500_charger_component_drivers, +ARRAY_SIZE (ab8500_charger_component_drivers)); +return ret; + } + +return 0 ; } static void __exit ab8500_charger_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 521/731 power: supply: fix null pointer dereferencing in power_supply_get_battery_info
In reply to Greg Kroah-HartmanFrom: ruanjinjie <[email protected]>
[ Upstream commit 104bb8a663451404a26331263ce5b96c34504049 ]
when kmalloc() fail to allocate memory in kasprintf(), propname will be NULL, strcmp() called by of_get_property() will cause null pointer dereference.
So return ENOMEM if kasprintf() return NULL pointer.
--- drivers/power/supply/power_supply_core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/power/supply/power_supply_core.c +5 -0
@@ -696,6 +696,11 @@ int power_supply_get_battery_info(struct power_supply *psy,int i, tab_len, size; propname =kasprintf (GFP_KERNEL ,"ocv-capacity-table-%d" , index); +if (!propname) { +power_supply_put_battery_info (psy, info); + err = -ENOMEM ; + goto out_put_node; + } list =of_get_property (battery_np, propname, &size);if (!list || !size) {dev_err (&psy->dev,"failed to get %s\n" , propname);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 522/731 perf stat: Refactor __run_perf_stat() common code
In reply to Greg Kroah-HartmanFrom: Adrián Herrera Arcila <[email protected]>
[ Upstream commit bb8bc52e75785af94b9ba079277547d50d018a52 ]
This extracts common code from the branches of the forks if-then-else.
enable_counters(), which was at the beginning of both branches of the conditional, is now unconditional; evlist__start_workload() is extracted to a different if, which enables making the common clocking code unconditional.
Stable-dep-of: c587e77e100f ("perf stat: Do not delay the workload with --delay")
--- tools/perf/builtin-stat.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
tools/perf/builtin-stat.c +9 -16
@@ -953,18 +953,18 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)return err; } -/* -* Enable counters and exec the command: -*/ -if (forks) { - err =enable_counters (); -if (err) -return -1 ; + err =enable_counters (); +if (err) +return -1 ; + +/* Exec the command, if any */ +if (forks)evlist__start_workload (evsel_list); - t0 =rdclock (); -clock_gettime (CLOCK_MONOTONIC , &ref_time); + t0 =rdclock (); +clock_gettime (CLOCK_MONOTONIC , &ref_time); +if (forks) {if (interval || timeout ||evlist__ctlfd_initialized (evsel_list)) status =dispatch_events (forks, timeout, interval, ×);if (child_pid !=-1 ) {
@@ -982,13 +982,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)if (WIFSIGNALED (status))psignal (WTERMSIG (status), argv[0 ]); }else { - err =enable_counters (); -if (err) -return -1 ; - - t0 =rdclock (); -clock_gettime (CLOCK_MONOTONIC , &ref_time); - status =dispatch_events (forks, timeout, interval, ×); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 523/731 perf stat: Do not delay the workload with --delay
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit c587e77e100fa40eb6af10e00497c67acf493f33 ]
The -D/--delay option is to delay the measure after the program starts. But the current code goes to sleep before starting the program so the program is delayed too. This is not the intention, let's fix it.
Before:
$ time sudo ./perf stat -a -e cycles -D 3000 sleep 4 Events disabled Events enabled
Performance counter stats for 'system wide':
4,326,949,337 cycles
4.007494118 seconds time elapsed real 0m7.474s
user 0m0.356s
sys 0m0.120s
It ran the workload for 4 seconds and gave the 3 second delay. So it should skip the first 3 second and measure the last 1 second only. But as you can see, it delays 3 seconds and ran the workload after that for 4 seconds. So the total time (real) was 7 seconds.
After:
$ time sudo ./perf stat -a -e cycles -D 3000 sleep 4 Events disabled Events enabled
Performance counter stats for 'system wide':
1,063,551,013 cycles
1.002769510 seconds time elapsed real 0m4.484s
user 0m0.385s
sys 0m0.086s
The bug was introduced when it changed enablement of system-wide events with a command line workload. But it should've considered the initial delay case. The code was reworked since then (in bb8bc52e7578) so I'm afraid it won't be applied cleanly.
--- tools/perf/builtin-stat.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
tools/perf/builtin-stat.c +17 -16
@@ -558,26 +558,14 @@ static int enable_counters(void)return err; } -if (stat_config.initial_delay <0 ) { -pr_info (EVLIST_DISABLED_MSG ); -return 0 ; - } - -if (stat_config.initial_delay >0 ) { -pr_info (EVLIST_DISABLED_MSG ); -usleep (stat_config.initial_delay *USEC_PER_MSEC ); - } -/* * We need to enable counters only if: * - we don't have tracee (attaching to task or cpu) * - we have initial delay configured */ -if (!target__none (&target) || stat_config.initial_delay) { +if (!target__none (&target)) {if (!all_counters_use_bpf)evlist__enable (evsel_list); -if (stat_config.initial_delay >0 ) -pr_info (EVLIST_ENABLED_MSG ); }return 0 ; }
@@ -953,14 +941,27 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)return err; } - err =enable_counters (); -if (err) -return -1 ; +if (stat_config.initial_delay) { +pr_info (EVLIST_DISABLED_MSG ); + }else { + err =enable_counters (); +if (err) +return -1 ; + }/* Exec the command, if any */ if (forks)evlist__start_workload (evsel_list); +if (stat_config.initial_delay >0 ) { +usleep (stat_config.initial_delay *USEC_PER_MSEC ); + err =enable_counters (); +if (err) +return -1 ; + +pr_info (EVLIST_ENABLED_MSG ); + } + t0 =rdclock ();clock_gettime (CLOCK_MONOTONIC , &ref_time);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 524/731 RDMA/siw: Fix pointer cast warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 5244ca88671a1981ceec09c5c8809f003e6a62aa ]
The previous build fix left a remaining issue in configurations with 64-bit dma_addr_t on 32-bit architectures:
drivers/infiniband/sw/siw/siw_qp_tx.c: In function 'siw_get_pblpage':drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
32 | return virt_to_page((void *)paddr);
| ^
Use the same double cast here that the driver uses elsewhere to convert between dma_addr_t and void*.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
@@ -29,7 +29,7 @@ static struct page *siw_get_pblpage(struct siw_mem *mem, u64 addr, int *idx)dma_addr_t paddr =siw_pbl_get_buffer (pbl, offset,NULL , idx);if (paddr) -return virt_to_page ((void *)paddr); +return virt_to_page ((void *)(uintptr_t )paddr);return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 525/731 fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit caad9dd8792a2622737b7273cb34835fd9536cd2 ]
syzbot reported UBSAN error as below:
[ 76.901829][ T6677] ================================================================================ [ 76.903908][ T6677] UBSAN: shift-out-of-bounds in fs/ntfs3/super.c:675:13 [ 76.905363][ T6677] shift exponent -247 is negative
This patch avoid this error.
--- fs/ntfs3/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/super.c +1 -1
@@ -672,7 +672,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)if (boot->sectors_per_clusters <=0x80 )return boot->sectors_per_clusters;if (boot->sectors_per_clusters >=0xf4 )/* limit shift to 2MB max */ -return 1U << (0 - boot->sectors_per_clusters); +return 1U << -(s8 )boot->sectors_per_clusters;return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 526/731 overflow: Implement size_t saturating arithmetic helpers
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit e1be43d9b5d0d1310dbd90185a8e5c7145dde40f ]
In order to perform more open-coded replacements of common allocation size arithmetic, the kernel needs saturating (SIZE_MAX) helpers for multiplication, addition, and subtraction. For example, it is common in allocators, especially on realloc, to add to an existing size:
p = krealloc(map->patch,
sizeof(struct reg_sequence) * (map->patch_regs + num_regs),
GFP_KERNEL);There is no existing saturating replacement for this calculation, and just leaving the addition open coded inside array_size() could potentially overflow as well. For example, an overflow in an expression for a size_t argument might wrap to zero:
array_size(anything, something_at_size_max + 1) == 0
Introduce size_mul(), size_add(), and size_sub() helpers that implicitly promote arguments to size_t and saturated calculations for use in allocations. With these helpers it is also possible to redefine array_size(), array3_size(), flex_array_size(), and struct_size() in terms of the new helpers.
As with the check_*_overflow() helpers, the new helpers use __must_check, though what is really desired is a way to make sure that assignment is only to a size_t lvalue. Without this, it's still possible to introduce overflow/underflow via type conversion (i.e. from size_t to int). Enforcing this will currently need to be left to static analysis or future use of -Wconversion.
Additionally update the overflow unit tests to force runtime evaluation for the pathological cases.
Stable-dep-of: e001e6086939 ("fs/ntfs3: Harden against integer overflows")
--- Documentation/process/deprecated.rst | 20 ++++- include/linux/overflow.h | 110 +++++++++++++++++---------- lib/test_overflow.c | 98 ++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 44 deletions(-)
Documentation/process/deprecated.rst +17 -3
@@ -70,6 +70,9 @@ Instead, the 2-factor form of the allocator should be used:: foo = kmalloc_array(count, size, GFP_KERNEL); +Specifically, kmalloc() can be replaced with kmalloc_array(), and +kzalloc() can be replaced with kcalloc(). + If no 2-factor form is available, the saturate-on-overflow helpers should be used::
@@ -90,9 +93,20 @@ Instead, use the helper:: array usage and switch to a `flexible array member <#zero-length-and-one-element-arrays>`_ instead. -See array_size(), array3_size(), and struct_size(), -for more details as well as the related check_add_overflow() and -check_mul_overflow() family of functions. +For other calculations, please compose the use of the size_mul(), +size_add(), and size_sub() helpers. For example, in the case of:: + + foo = krealloc(current_size + chunk_size * (count - 3), GFP_KERNEL); + +Instead, use the helpers:: + + foo = krealloc(size_add(current_size, + size_mul(chunk_size, + size_sub(count, 3))), GFP_KERNEL); + +For more details, also see array3_size() and flex_array_size(), +as well as the related check_mul_overflow(), check_add_overflow(), +check_sub_overflow(), and check_shl_overflow() family of functions. simple_strtol(), simple_strtoll(), simple_strtoul(), simple_strtoull() ----------------------------------------------------------------------
include/linux/overflow.h +69 -41
157 lines not on this page · raw message
lib/test_overflow.c +98 -0
110 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 527/731 fs/ntfs3: Harden against integer overflows
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e001e60869390686809663c02bceb1d3922548fb ]
Smatch complains that the "add_bytes" is not to be trusted. Use size_add() to prevent an integer overflow.
--- fs/ntfs3/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/xattr.c +1 -1
@@ -107,7 +107,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,return -EFBIG ;/* Allocate memory for packed Ea. */ - ea_p =kmalloc (size + add_bytes,GFP_NOFS ); + ea_p =kmalloc (size_add (size, add_bytes),GFP_NOFS );if (!ea_p)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 528/731 iommu/sun50i: Fix reset release
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 9ad0c1252e84dbc664f0462707182245ed603237 ]
Reset signal is asserted by writing 0 to the corresponding locations of masters we want to reset. So in order to deassert all reset signals, we should write 1's to all locations.
Current code writes 1's to locations of masters which were just reset which is good. However, at the same time it also writes 0's to other locations and thus asserts reset signals of remaining masters. Fix code by writing all 1's when we want to deassert all reset signals.
This bug was discovered when working with Cedrus (video decoder). When it faulted, display went blank due to reset signal assertion.
--- drivers/iommu/sun50i-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +2 -1
@@ -27,6 +27,7 @@#include <linux/types.h> #define IOMMU_RESET_REG 0x010 +#define IOMMU_RESET_RELEASE_ALL 0xffffffff#define IOMMU_ENABLE_REG 0x020#define IOMMU_ENABLE_ENABLE BIT(0)
@@ -894,7 +895,7 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)iommu_write (iommu,IOMMU_INT_CLR_REG , status);iommu_write (iommu,IOMMU_RESET_REG , ~status); -iommu_write (iommu,IOMMU_RESET_REG , status); +iommu_write (iommu,IOMMU_RESET_REG ,IOMMU_RESET_RELEASE_ALL );spin_unlock (&iommu->iommu_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 529/731 iommu/sun50i: Consider all fault sources for reset
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit cef20703e2b2276aaa402ec5a65ec9a09963b83e ]
We have to reset masters for all faults - permissions, L1 fault or L2 fault. Currently it's done only for permissions. If other type of fault happens, master is in locked up state. Fix that by really considering all fault sources.
--- drivers/iommu/sun50i-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iommu/sun50i-iommu.c +6 -2
@@ -870,8 +870,8 @@ static phys_addr_t sun50i_iommu_handle_perm_irq(struct sun50i_iommu *iommu)static irqreturn_t sun50i_iommu_irq (int irq,void *dev_id) { +u32 status, l1_status, l2_status, resets;struct sun50i_iommu *iommu = dev_id; -u32 status;spin_lock (&iommu->iommu_lock);
@@ -881,6 +881,9 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)return IRQ_NONE ; } + l1_status =iommu_read (iommu,IOMMU_L1PG_INT_REG ); + l2_status =iommu_read (iommu,IOMMU_L2PG_INT_REG ); +if (status &IOMMU_INT_INVALID_L2PG ) sun50i_iommu_handle_pt_irq(iommu, IOMMU_INT_ERR_ADDR_L2_REG,
@@ -894,7 +897,8 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)iommu_write (iommu,IOMMU_INT_CLR_REG , status); -iommu_write (iommu,IOMMU_RESET_REG , ~status); + resets = (status | l1_status | l2_status) &IOMMU_INT_MASTER_MASK ; +iommu_write (iommu,IOMMU_RESET_REG , ~resets);iommu_write (iommu,IOMMU_RESET_REG ,IOMMU_RESET_RELEASE_ALL );spin_unlock (&iommu->iommu_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 530/731 iommu/sun50i: Fix R/W permission check
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit eac0104dc69be50bed86926d6f32e82b44f8c921 ]
Because driver has enum type permissions and iommu subsystem has bitmap type, we have to be careful how check for combined read and write permissions is done. In such case, we have to mask both permissions and check that both are set at the same time.
Current code just masks both flags but doesn't check that both are set. In short, it always sets R/W permission, regardles if requested permissions were RO, WO or RW. Fix that.
--- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +1 -1
@@ -271,7 +271,7 @@ static u32 sun50i_mk_pte(phys_addr_t page, int prot)enum sun50i_iommu_aci aci;u32 flags =0 ; -if (prot & (IOMMU_READ |IOMMU_WRITE )) +if ((prot & (IOMMU_READ |IOMMU_WRITE )) == (IOMMU_READ |IOMMU_WRITE )) aci =SUN50I_IOMMU_ACI_RD_WR ;else if (prot &IOMMU_READ ) aci =SUN50I_IOMMU_ACI_RD ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 531/731 iommu/sun50i: Fix flush size
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 67a8a67f9eceb72e4c73d1d09ed9ab04f4b8e12d ]
Function sun50i_table_flush() takes number of entries as an argument, not number of bytes. Fix that mistake in sun50i_dte_get_page_table().
--- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +1 -1
@@ -512,7 +512,7 @@ static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain *sun50i_domain,sun50i_iommu_free_page_table (iommu, drop_pt); } -sun50i_table_flush (sun50i_domain, page_table,PT_SIZE ); +sun50i_table_flush (sun50i_domain, page_table,NUM_PT_ENTRIES );sun50i_table_flush (sun50i_domain, dte_addr,1 );return page_table;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 532/731 iommu/rockchip: fix permission bits in page table entries v2
In reply to Greg Kroah-HartmanFrom: Michael Riesch <[email protected]>
[ Upstream commit 7eb99841f340b80be0d0973b0deb592d75fb8928 ]
As pointed out in the corresponding downstream fix [0], the permission bits of the page table entries are compatible between v1 and v2 of the IOMMU. This is in contrast to the current mainline code that incorrectly assumes that the read and write permission bits are switched. Fix the permission bits by reusing the v1 bit defines.
[0] https://github.com/rockchip-linux/kernel/commit/e3bc123a2260145e34b57454da3db0edd117eb8e
--- drivers/iommu/rockchip-iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iommu/rockchip-iommu.c +4 -6
@@ -280,19 +280,17 @@ static u32 rk_mk_pte(phys_addr_t page, int prot)* 11:9 - Page address bit 34:32 * 8:4 - Page address bit 39:35 * 3 - Security -* 2 - Readable -* 1 - Writable +* 2 - Writable +* 1 - Readable * 0 - 1 if Page @ Page address is valid */ -#define RK_PTE_PAGE_READABLE_V2 BIT(2) -#define RK_PTE_PAGE_WRITABLE_V2 BIT(1)static u32 rk_mk_pte_v2 (phys_addr_t page,int prot) {u32 flags =0 ; - flags |= (prot &IOMMU_READ ) ?RK_PTE_PAGE_READABLE_V2 :0 ; - flags |= (prot &IOMMU_WRITE ) ?RK_PTE_PAGE_WRITABLE_V2 :0 ; + flags |= (prot &IOMMU_READ ) ?RK_PTE_PAGE_READABLE :0 ; + flags |= (prot &IOMMU_WRITE ) ?RK_PTE_PAGE_WRITABLE :0 ;return rk_mk_dte_v2 (page) | flags; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 533/731 phy: usb: s2 WoL wakeup_count not incremented for USB->Eth devices
In reply to Greg Kroah-HartmanFrom: Al Cooper <[email protected]>
[ Upstream commit f7fc5b7090372fc4dd7798c874635ca41b8ba733 ]
The PHY's "wakeup_count" is not incrementing when waking from WoL. The wakeup count can be found in sysfs at:/sys/bus/platform/devices/rdb/*.usb-phy/power/wakeup_count. The problem is that the system wakup event handler was being passed the wrong "device" by the PHY driver.
--- drivers/phy/broadcom/phy-brcm-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/broadcom/phy-brcm-usb.c +3 -3
@@ -102,9 +102,9 @@ static int brcm_pm_notifier(struct notifier_block *notifier,static irqreturn_t brcm_usb_phy_wake_isr (int irq,void *dev_id) { -struct phy *gphy = dev_id; +struct device *dev = dev_id; -pm_wakeup_event (&gphy->dev,0 ); +pm_wakeup_event (dev,0 );return IRQ_HANDLED ; }
@@ -451,7 +451,7 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev,if (priv->wake_irq >=0 ) { err =devm_request_irq (dev, priv->wake_irq, brcm_usb_phy_wake_isr,0 , -dev_name (dev), gphy); +dev_name (dev), dev);if (err <0 )return err;device_set_wakeup_capable (dev,1 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 534/731 include/uapi/linux/swab: Fix potentially missing __always_inline
In reply to Greg Kroah-HartmanFrom: Matt Redfearn <[email protected]>
[ Upstream commit defbab270d45e32b068e7e73c3567232d745c60f ]
Commit bc27fb68aaad ("include/uapi/linux/byteorder, swab: force inlining of some byteswap operations") added __always_inline to swab functions and commit 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to userspace headers") added a definition of __always_inline for use in exported headers when the kernel's compiler.h is not available.
However, since swab.h does not include stddef.h, if the header soup does not indirectly include it, the definition of __always_inline is missing, resulting in a compilation failure, which was observed compiling the perf tool using exported headers containing this commit:
In file included from /usr/include/linux/byteorder/little_endian.h:12:0,
from /usr/include/asm/byteorder.h:14,
from tools/include/uapi/linux/perf_event.h:20,
from perf.h:8,
from builtin-bench.c:18:/usr/include/linux/swab.h:160:8: error: unknown type name `__always_inline'
static __always_inline __u16 __swab16p(const __u16 *p)
Fix this by replacing the inclusion of linux/compiler.h with linux/stddef.h to ensure that we pick up that definition if required, without relying on it's indirect inclusion. compiler.h is then included indirectly, via stddef.h.
--- include/uapi/linux/swab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/swab.h +1 -1
@@ -3,7 +3,7 @@#define _UAPI_LINUX_SWAB_H#include <linux/types.h> -#include <linux/compiler.h> +#include <linux/stddef.h> #include <asm/bitsperlong.h> #include <asm/swab.h>
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 535/731 pwm: tegra: Improve required rate calculation
In reply to Greg Kroah-HartmanFrom: Jon Hunter <[email protected]>
[ Upstream commit f271946117dde2ca8741b8138b347b2d68e6ad56 ]
For the case where dev_pm_opp_set_rate() is called to set the PWM clock rate, the requested rate is calculated as ...
required_clk_rate = (NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH;
The above calculation may lead to rounding errors because the NSEC_PER_SEC is divided by 'period_ns' before applying the PWM_DUTY_WIDTH multiplication factor. For example, if the period is 45334ns, the above calculation yields a rate of 5646848Hz instead of 5646976Hz. Fix this by applying the multiplication factor before dividing and using the DIV_ROUND_UP macro which yields the expected result of 5646976Hz.
--- drivers/pwm/pwm-tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-tegra.c +2 -2
@@ -142,8 +142,8 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,* source clock rate as required_clk_rate, PWM controller will * be able to configure the requested period. */ - required_clk_rate = - (NSEC_PER_SEC / period_ns) <<PWM_DUTY_WIDTH ; + required_clk_rate =DIV_ROUND_UP_ULL (NSEC_PER_SEC <<PWM_DUTY_WIDTH , + period_ns); err =clk_set_rate (pc->clk, required_clk_rate);if (err <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 536/731 fs/ntfs3: Fix slab-out-of-bounds read in ntfs_trim_fs
In reply to Greg Kroah-HartmanFrom: Abdun Nihaal <[email protected]>
[ Upstream commit 557d19675a470bb0a98beccec38c5dc3735c20fa ]
Syzbot reports an out of bound access in ntfs_trim_fs.
The cause of this is using a loop termination condition that compares window index (iw) with wnd->nbits instead of wnd->nwnd, due to which the index used for wnd->free_bits exceeds the size of the array allocated.
Fix the loop condition.
--- fs/ntfs3/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/bitmap.c +1 -1
@@ -1432,7 +1432,7 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range)down_read_nested (&wnd->rw_lock,BITMAP_MUTEX_CLUSTERS ); -for (; iw < wnd->nbits; iw++, wbit =0 ) { +for (; iw < wnd->nwnd; iw++, wbit =0 ) {CLST lcn_wnd = iw * wbits;struct buffer_head *bh;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 537/731 dmaengine: idxd: Fix crc_val field for completion record
In reply to Greg Kroah-HartmanFrom: Fenghua Yu <[email protected]>
[ Upstream commit dc901d98b1fe6e52ab81cd3e0879379168e06daa ]
The crc_val in the completion record should be 64 bits and not 32 bits.
--- include/uapi/linux/idxd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/idxd.h +1 -1
@@ -272,7 +272,7 @@ struct dsa_completion_record { };uint32_t delta_rec_size; -uint32_t crc_val; +uint64_t crc_val;/* DIF check & strip */ struct {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 538/731 rtc: rtc-cmos: Do not check ACPI_FADT_LOW_POWER_S0
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 6492fed7d8c95f53b0b804ef541324d924d95d41 ]
The ACPI_FADT_LOW_POWER_S0 flag merely means that it is better to use low-power S0 idle on the given platform than S3 (provided that the latter is supported) and it doesn't preclude using either of them (which of them will be used depends on the choices made by user space).
For this reason, there is no benefit from checking that flag in use_acpi_alarm_quirks().
First off, it cannot be a bug to do S3 with use_acpi_alarm set, because S3 can be used on systems with ACPI_FADT_LOW_POWER_S0 and it must work if really supported, so the ACPI_FADT_LOW_POWER_S0 check is not needed to protect the S3-capable systems from failing.
Second, suspend-to-idle can be carried out on a system with ACPI_FADT_LOW_POWER_S0 unset and it is expected to work, so if setting use_acpi_alarm is needed to handle that case correctly, it should be set regardless of the ACPI_FADT_LOW_POWER_S0 value.
Accordingly, drop the ACPI_FADT_LOW_POWER_S0 check from use_acpi_alarm_quirks().
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 3 --- 1 file changed, 3 deletions(-)
drivers/rtc/rtc-cmos.c +0 -3
@@ -1260,9 +1260,6 @@ static void use_acpi_alarm_quirks(void)if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL )return ; -if (!(acpi_gbl_FADT.flags &ACPI_FADT_LOW_POWER_S0 )) -return ; -if (!is_hpet_enabled ())return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 539/731 rtc: cmos: Fix event handler registration ordering issue
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 4919d3eb2ec0ee364f7e3cf2d99646c1b224fae8 ]
Because acpi_install_fixed_event_handler() enables the event automatically on success, it is incorrect to call it before the handler routine passed to it is ready to handle events.
Unfortunately, the rtc-cmos driver does exactly the incorrect thing by calling cmos_wake_setup(), which passes rtc_handler() to acpi_install_fixed_event_handler(), before cmos_do_probe(), because rtc_handler() uses dev_get_drvdata() to get to the cmos object pointer and the driver data pointer is only populated in cmos_do_probe().
This leads to a NULL pointer dereference in rtc_handler() on boot if the RTC fixed event happens to be active at the init time.
To address this issue, change the initialization ordering of the driver so that cmos_wake_setup() is always called after a successful cmos_do_probe() call.
While at it, change cmos_pnp_probe() to call cmos_do_probe() after the initial if () statement used for computing the IRQ argument to be passed to cmos_do_probe() which is cleaner than calling it in each branch of that if () (local variable "irq" can be of type int, because it is passed to that function as an argument of type int).
Note that commit 6492fed7d8c9 ("rtc: rtc-cmos: Do not check ACPI_FADT_LOW_POWER_S0") caused this issue to affect a larger number of systems, because previously it only affected systems with ACPI_FADT_LOW_POWER_S0 set, but it is present regardless of that commit.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/rtc/rtc-cmos.c +19 -10
@@ -1352,10 +1352,10 @@ static void cmos_check_acpi_rtc_status(struct device *dev,static int cmos_pnp_probe (struct pnp_dev *pnp,const struct pnp_device_id *id) { -cmos_wake_setup (&pnp->dev); +int irq, ret;if (pnp_port_start (pnp,0 ) ==0x70 && !pnp_irq_valid (pnp,0 )) { -unsigned int irq =0 ; + irq =0 ;#ifdef CONFIG_X86 /* Some machines contain a PNP entry for the RTC, but * don't define the IRQ. It should always be safe to
@@ -1364,13 +1364,17 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)if (nr_legacy_irqs ()) irq =RTC_IRQ ;#endif -return cmos_do_probe (&pnp->dev, -pnp_get_resource (pnp,IORESOURCE_IO ,0 ), irq); }else { -return cmos_do_probe (&pnp->dev, -pnp_get_resource (pnp,IORESOURCE_IO ,0 ), -pnp_irq (pnp,0 )); + irq =pnp_irq (pnp,0 ); } + + ret =cmos_do_probe (&pnp->dev,pnp_get_resource (pnp,IORESOURCE_IO ,0 ), irq); +if (ret) +return ret; + +cmos_wake_setup (&pnp->dev); + +return 0 ; }static void cmos_pnp_remove (struct pnp_dev *pnp)
@@ -1454,10 +1458,9 @@ static inline void cmos_of_init(struct platform_device *pdev) {}static int __init cmos_platform_probe (struct platform_device *pdev) {struct resource *resource; -int irq; +int irq, ret;cmos_of_init (pdev); -cmos_wake_setup (&pdev->dev);if (RTC_IOMAPPED ) resource =platform_get_resource (pdev,IORESOURCE_IO ,0 );
@@ -1467,7 +1470,13 @@ static int __init cmos_platform_probe(struct platform_device *pdev)if (irq <0 ) irq =-1 ; -return cmos_do_probe (&pdev->dev, resource, irq); + ret =cmos_do_probe (&pdev->dev, resource, irq); +if (ret) +return ret; + +cmos_wake_setup (&pdev->dev); + +return 0 ; }static int cmos_platform_remove (struct platform_device *pdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 540/731 rtc: cmos: Fix wake alarm breakage
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 0782b66ed2fbb035dda76111df0954515e417b24 ]
Commit 4919d3eb2ec0 ("rtc: cmos: Fix event handler registration ordering issue") overlooked the fact that cmos_do_probe() depended on the preparations carried out by cmos_wake_setup() and the wake alarm stopped working after the ordering of them had been changed.
Address this by partially reverting commit 4919d3eb2ec0 so that cmos_wake_setup() is called before cmos_do_probe() again and moving the rtc_wake_setup() invocation from cmos_wake_setup() directly to the callers of cmos_do_probe() where it will happen after a successful completion of the latter.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/rtc/rtc-cmos.c +8 -3
@@ -1233,6 +1233,9 @@ static u32 rtc_handler(void *context)static inline void rtc_wake_setup (struct device *dev) { +if (acpi_disabled) +return ; +acpi_install_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler, dev);/* * After the RTC handler is installed, the Fixed_RTC event should
@@ -1286,7 +1289,6 @@ static void cmos_wake_setup(struct device *dev)use_acpi_alarm_quirks (); -rtc_wake_setup (dev); acpi_rtc_info.wake_on = rtc_wake_on; acpi_rtc_info.wake_off = rtc_wake_off;
@@ -1354,6 +1356,8 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) {int irq, ret; +cmos_wake_setup (&pnp->dev); +if (pnp_port_start (pnp,0 ) ==0x70 && !pnp_irq_valid (pnp,0 )) { irq =0 ;#ifdef CONFIG_X86
@@ -1372,7 +1376,7 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)if (ret)return ret; -cmos_wake_setup (&pnp->dev); +rtc_wake_setup (&pnp->dev);return 0 ; }
@@ -1461,6 +1465,7 @@ static int __init cmos_platform_probe(struct platform_device *pdev)int irq, ret;cmos_of_init (pdev); +cmos_wake_setup (&pdev->dev);if (RTC_IOMAPPED ) resource =platform_get_resource (pdev,IORESOURCE_IO ,0 );
@@ -1474,7 +1479,7 @@ static int __init cmos_platform_probe(struct platform_device *pdev)if (ret)return ret; -cmos_wake_setup (&pdev->dev); +rtc_wake_setup (&pdev->dev);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 541/731 rtc: cmos: fix build on non-ACPI platforms
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
[ Upstream commit db4e955ae333567dea02822624106c0b96a2f84f ]
Now that rtc_wake_setup is called outside of cmos_wake_setup, it also need to be defined on non-ACPI platforms.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/rtc/rtc-cmos.c +3 -0
@@ -1346,6 +1346,9 @@ static void cmos_check_acpi_rtc_status(struct device *dev, { } +static void rtc_wake_setup (struct device *dev) +{ +}#endif #ifdef CONFIG_PNP
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 542/731 rtc: cmos: Call cmos_wake_setup() from cmos_do_probe()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 508ccdfb86b21da37ad091003a4d4567709d5dfb ]
Notice that cmos_wake_setup() is the only user of acpi_rtc_info and it can operate on the cmos_rtc variable directly, so it need not set the platform_data pointer before cmos_do_probe() is called. Instead, it can be called by cmos_do_probe() in the case when the platform_data pointer is not set to implement the default behavior (which is to use the FADT information as long as ACPI support is enabled).
Modify the code accordingly.
While at it, drop a comment that doesn't really match the code it is supposed to be describing.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 47 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-)
drivers/rtc/rtc-cmos.c +22 -25
@@ -744,6 +744,8 @@ static irqreturn_t cmos_interrupt(int irq, void *p)return IRQ_NONE ; } +static void cmos_wake_setup (struct device *dev); +#ifdef CONFIG_PNP #define INITSECTION
@@ -827,19 +829,27 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)if (info->address_space) address_space = info->address_space; -if (info->rtc_day_alarm && info->rtc_day_alarm <128 ) - cmos_rtc.day_alrm = info->rtc_day_alarm; -if (info->rtc_mon_alarm && info->rtc_mon_alarm <128 ) - cmos_rtc.mon_alrm = info->rtc_mon_alarm; -if (info->rtc_century && info->rtc_century <128 ) - cmos_rtc.century = info->rtc_century; + cmos_rtc.day_alrm = info->rtc_day_alarm; + cmos_rtc.mon_alrm = info->rtc_mon_alarm; + cmos_rtc.century = info->rtc_century;if (info->wake_on && info->wake_off) { cmos_rtc.wake_on = info->wake_on; cmos_rtc.wake_off = info->wake_off; } + }else { +cmos_wake_setup (dev); } +if (cmos_rtc.day_alrm >=128 ) + cmos_rtc.day_alrm =0 ; + +if (cmos_rtc.mon_alrm >=128 ) + cmos_rtc.mon_alrm =0 ; + +if (cmos_rtc.century >=128 ) + cmos_rtc.century =0 ; + cmos_rtc.dev = dev;dev_set_drvdata (dev, &cmos_rtc);
@@ -1275,13 +1285,6 @@ static void use_acpi_alarm_quirks(void)static inline void use_acpi_alarm_quirks (void ) { }#endif -/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find -* its device node and pass extra config data. This helps its driver use -* capabilities that the now-obsolete mc146818 didn't have, and informs it -* that this board's RTC is wakeup-capable (per ACPI spec). -*/ -static struct cmos_rtc_board_info acpi_rtc_info; -static void cmos_wake_setup (struct device *dev) {if (acpi_disabled)
@@ -1289,26 +1292,23 @@ static void cmos_wake_setup(struct device *dev)use_acpi_alarm_quirks (); - acpi_rtc_info.wake_on = rtc_wake_on; - acpi_rtc_info.wake_off = rtc_wake_off; + cmos_rtc.wake_on = rtc_wake_on; + cmos_rtc.wake_off = rtc_wake_off; -/* workaround bug in some ACPI tables */ +/* ACPI tables bug workaround. */ if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) {dev_dbg (dev,"bogus FADT month_alarm (%d)\n" , acpi_gbl_FADT.month_alarm); acpi_gbl_FADT.month_alarm =0 ; } - acpi_rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm; - acpi_rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm; - acpi_rtc_info.rtc_century = acpi_gbl_FADT.century; + cmos_rtc.day_alrm = acpi_gbl_FADT.day_alarm; + cmos_rtc.mon_alrm = acpi_gbl_FADT.month_alarm; + cmos_rtc.century = acpi_gbl_FADT.century; -/* NOTE: S4_RTC_WAKE is NOT currently useful to Linux */ if (acpi_gbl_FADT.flags &ACPI_FADT_S4_RTC_WAKE )dev_info (dev,"RTC can wake from S4\n" ); - dev->platform_data = &acpi_rtc_info; -/* RTC always wakes from S1/S2/S3, and often S4/STD */ device_init_wakeup (dev,1 ); }
@@ -1359,8 +1359,6 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) {int irq, ret; -cmos_wake_setup (&pnp->dev); -if (pnp_port_start (pnp,0 ) ==0x70 && !pnp_irq_valid (pnp,0 )) { irq =0 ;#ifdef CONFIG_X86
@@ -1468,7 +1466,6 @@ static int __init cmos_platform_probe(struct platform_device *pdev)int irq, ret;cmos_of_init (pdev); -cmos_wake_setup (&pdev->dev);if (RTC_IOMAPPED ) resource =platform_get_resource (pdev,IORESOURCE_IO ,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 543/731 rtc: cmos: Call rtc_wake_setup() from cmos_do_probe()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 375bbba09692fe4c5218eddee8e312dd733fa846 ]
To reduce code duplication, move the invocation of rtc_wake_setup() into cmos_do_probe() and simplify the callers of the latter.
No intentional functional impact.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/rtc/rtc-cmos.c +12 -16
@@ -744,6 +744,7 @@ static irqreturn_t cmos_interrupt(int irq, void *p)return IRQ_NONE ; } +static inline void rtc_wake_setup (struct device *dev);static void cmos_wake_setup (struct device *dev);#ifdef CONFIG_PNP
@@ -938,6 +939,13 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) nvmem_cfg.size = address_space -NVRAM_OFFSET ;devm_rtc_nvmem_register (cmos_rtc.rtc, &nvmem_cfg); +/* +* Everything has gone well so far, so by default register a handler for +* the ACPI RTC fixed event. +*/ +if (!info) +rtc_wake_setup (dev); +dev_info (dev,"%s%s, %d bytes nvram%s\n" , !is_valid_irq (rtc_irq) ?"no alarms" : cmos_rtc.mon_alrm ? "alarms up to one year" :
@@ -1357,7 +1365,7 @@ static void rtc_wake_setup(struct device *dev)static int cmos_pnp_probe (struct pnp_dev *pnp,const struct pnp_device_id *id) { -int irq, ret; +int irq;if (pnp_port_start (pnp,0 ) ==0x70 && !pnp_irq_valid (pnp,0 )) { irq =0 ;
@@ -1373,13 +1381,7 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) irq =pnp_irq (pnp,0 ); } - ret =cmos_do_probe (&pnp->dev,pnp_get_resource (pnp,IORESOURCE_IO ,0 ), irq); -if (ret) -return ret; - -rtc_wake_setup (&pnp->dev); - -return 0 ; +return cmos_do_probe (&pnp->dev,pnp_get_resource (pnp,IORESOURCE_IO ,0 ), irq); }static void cmos_pnp_remove (struct pnp_dev *pnp)
@@ -1463,7 +1465,7 @@ static inline void cmos_of_init(struct platform_device *pdev) {}static int __init cmos_platform_probe (struct platform_device *pdev) {struct resource *resource; -int irq, ret; +int irq;cmos_of_init (pdev);
@@ -1475,13 +1477,7 @@ static int __init cmos_platform_probe(struct platform_device *pdev)if (irq <0 ) irq =-1 ; - ret =cmos_do_probe (&pdev->dev, resource, irq); -if (ret) -return ret; - -rtc_wake_setup (&pdev->dev); - -return 0 ; +return cmos_do_probe (&pdev->dev, resource, irq); }static int cmos_platform_remove (struct platform_device *pdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 544/731 rtc: cmos: Eliminate forward declarations of some functions
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit dca4d3b71c8a09a16951add656711fbd6f5bfbb0 ]
Reorder the ACPI-related code before cmos_do_probe() so as to eliminate excessive forward declarations of some functions.
While at it, for consistency, add the inline modifier to the definitions of empty stub static funtions and remove it from the corresponding definitions of functions with non-empty bodies.
No intentional functional impact.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 304 ++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 155 deletions(-)
drivers/rtc/rtc-cmos.c +149 -155
@@ -744,8 +744,155 @@ static irqreturn_t cmos_interrupt(int irq, void *p)return IRQ_NONE ; } -static inline void rtc_wake_setup (struct device *dev); -static void cmos_wake_setup (struct device *dev); +#ifdef CONFIG_ACPI + +#include <linux/acpi.h> + +static u32 rtc_handler (void *context) +{ +struct device *dev = context; +struct cmos_rtc *cmos =dev_get_drvdata (dev); +unsigned char rtc_control =0 ; +unsigned char rtc_intr; +unsigned long flags; + + +/* +* Always update rtc irq when ACPI is used as RTC Alarm. +* Or else, ACPI SCI is enabled during suspend/resume only, +* update rtc irq in that case. +*/ +if (cmos_use_acpi_alarm ()) +cmos_interrupt (0 , (void *)cmos->rtc); +else { +/* Fix me: can we use cmos_interrupt() here as well? */ +spin_lock_irqsave (&rtc_lock, flags); +if (cmos_rtc.suspend_ctrl) + rtc_control =CMOS_READ (RTC_CONTROL ); +if (rtc_control &RTC_AIE ) { + cmos_rtc.suspend_ctrl &= ~RTC_AIE ; +CMOS_WRITE (rtc_control,RTC_CONTROL ); + rtc_intr =CMOS_READ (RTC_INTR_FLAGS ); +rtc_update_irq (cmos->rtc,1 , rtc_intr); + } +spin_unlock_irqrestore (&rtc_lock, flags); + } + +pm_wakeup_hard_event (dev); +acpi_clear_event (ACPI_EVENT_RTC ); +acpi_disable_event (ACPI_EVENT_RTC ,0 ); +return ACPI_INTERRUPT_HANDLED ; +} + +static void rtc_wake_setup (struct device *dev) +{ +if (acpi_disabled) +return ; + +acpi_install_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler, dev); +/* +* After the RTC handler is installed, the Fixed_RTC event should +* be disabled. Only when the RTC alarm is set will it be enabled. +*/ +acpi_clear_event (ACPI_EVENT_RTC ); +acpi_disable_event (ACPI_EVENT_RTC ,0 ); +} + +static void rtc_wake_on (struct device *dev) +{ +acpi_clear_event (ACPI_EVENT_RTC ); +acpi_enable_event (ACPI_EVENT_RTC ,0 ); +} + +static void rtc_wake_off (struct device *dev) +{ +acpi_disable_event (ACPI_EVENT_RTC ,0 ); +} + +#ifdef CONFIG_X86 +/* Enable use_acpi_alarm mode for Intel platforms no earlier than 2015 */ +static void use_acpi_alarm_quirks (void ) +{ +if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL ) +return ; + +if (!is_hpet_enabled ()) +return ; + +if (dmi_get_bios_year () <2015 ) +return ; + + use_acpi_alarm = true; +} +#else +static inline void use_acpi_alarm_quirks (void ) { } +#endif + +static void cmos_wake_setup (struct device *dev) +{ +if (acpi_disabled) +return ; + +use_acpi_alarm_quirks (); + + cmos_rtc.wake_on = rtc_wake_on; + cmos_rtc.wake_off = rtc_wake_off; + +/* ACPI tables bug workaround. */ +if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) { +dev_dbg (dev,"bogus FADT month_alarm (%d)\n" , + acpi_gbl_FADT.month_alarm); + acpi_gbl_FADT.month_alarm =0 ; + } + + cmos_rtc.day_alrm = acpi_gbl_FADT.day_alarm; + cmos_rtc.mon_alrm = acpi_gbl_FADT.month_alarm; + cmos_rtc.century = acpi_gbl_FADT.century; + +if (acpi_gbl_FADT.flags &ACPI_FADT_S4_RTC_WAKE ) +dev_info (dev,"RTC can wake from S4\n" ); + +/* RTC always wakes from S1/S2/S3, and often S4/STD */ +device_init_wakeup (dev,1 ); +} + +static void cmos_check_acpi_rtc_status (struct device *dev, +unsigned char *rtc_control) +{ +struct cmos_rtc *cmos =dev_get_drvdata (dev); +acpi_event_status rtc_status; +acpi_status status; + +if (acpi_gbl_FADT.flags &ACPI_FADT_FIXED_RTC ) +return ; + + status =acpi_get_event_status (ACPI_EVENT_RTC , &rtc_status); +if (ACPI_FAILURE (status)) { +dev_err (dev,"Could not get RTC status\n" ); + }else if (rtc_status &ACPI_EVENT_FLAG_SET ) { +unsigned char mask; + *rtc_control &= ~RTC_AIE ; +CMOS_WRITE (*rtc_control,RTC_CONTROL ); + mask =CMOS_READ (RTC_INTR_FLAGS ); +rtc_update_irq (cmos->rtc,1 , mask); + } +} + +#else /* !CONFIG_ACPI */ + +static inline void rtc_wake_setup (struct device *dev) +{ +} + +static inline void cmos_wake_setup (struct device *dev) +{ +} + +static inline void cmos_check_acpi_rtc_status (struct device *dev, +unsigned char *rtc_control) +{ +} +#endif /* CONFIG_ACPI */ #ifdef CONFIG_PNP #define INITSECTION
@@ -1140,9 +1287,6 @@ static void cmos_check_wkalrm(struct device *dev) } } -static void cmos_check_acpi_rtc_status (struct device *dev, -unsigned char *rtc_control); -static int __maybe_unused cmos_resume (struct device *dev) {struct cmos_rtc *cmos =dev_get_drvdata (dev);
@@ -1209,156 +1353,6 @@ static SIMPLE_DEV_PM_OPS(cmos_pm_ops, cmos_suspend, cmos_resume);* predate even PNPBIOS should set up platform_bus devices. */ -#ifdef CONFIG_ACPI - -#include <linux/acpi.h> - -static u32 rtc_handler (void *context) -{ -struct device *dev = context; -struct cmos_rtc *cmos =dev_get_drvdata (dev); -unsigned char rtc_control =0 ; -unsigned char rtc_intr; -unsigned long flags; - - -/* -* Always update rtc irq when ACPI is used as RTC Alarm. -* Or else, ACPI SCI is enabled during suspend/resume only, -* update rtc irq in that case. -*/ -if (cmos_use_acpi_alarm ()) -cmos_interrupt (0 , (void *)cmos->rtc); -else { -/* Fix me: can we use cmos_interrupt() here as well? */ -spin_lock_irqsave (&rtc_lock, flags); -if (cmos_rtc.suspend_ctrl) - rtc_control =CMOS_READ (RTC_CONTROL ); -if (rtc_control &RTC_AIE ) { - cmos_rtc.suspend_ctrl &= ~RTC_AIE ; -CMOS_WRITE (rtc_control,RTC_CONTROL ); - rtc_intr =CMOS_READ (RTC_INTR_FLAGS ); -rtc_update_irq (cmos->rtc,1 , rtc_intr); - } -spin_unlock_irqrestore (&rtc_lock, flags); - } - -pm_wakeup_hard_event (dev); -acpi_clear_event (ACPI_EVENT_RTC ); -acpi_disable_event (ACPI_EVENT_RTC ,0 ); -return ACPI_INTERRUPT_HANDLED ; -} - -static inline void rtc_wake_setup (struct device *dev) -{ -if (acpi_disabled) -return ; - -acpi_install_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler, dev); -/* -* After the RTC handler is installed, the Fixed_RTC event should -* be disabled. Only when the RTC alarm is set will it be enabled. -*/ -acpi_clear_event (ACPI_EVENT_RTC ); -acpi_disable_event (ACPI_EVENT_RTC ,0 ); -} - -static void rtc_wake_on (struct device *dev) -{ -acpi_clear_event (ACPI_EVENT_RTC ); -acpi_enable_event (ACPI_EVENT_RTC ,0 ); -} - -static void rtc_wake_off (struct device *dev) -{ -acpi_disable_event (ACPI_EVENT_RTC ,0 ); -} - -#ifdef CONFIG_X86 -/* Enable use_acpi_alarm mode for Intel platforms no earlier than 2015 */ -static void use_acpi_alarm_quirks (void ) -{ -if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL ) -return ; - -if (!is_hpet_enabled ()) -return ; - -if (dmi_get_bios_year () <2015 ) -return ; - - use_acpi_alarm = true; -} -#else -static inline void use_acpi_alarm_quirks (void ) { } -#endif - -static void cmos_wake_setup (struct device *dev) -{ -if (acpi_disabled) -return ; - -use_acpi_alarm_quirks (); - - cmos_rtc.wake_on = rtc_wake_on; - cmos_rtc.wake_off = rtc_wake_off; - -/* ACPI tables bug workaround. */ -if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) { -dev_dbg (dev,"bogus FADT month_alarm (%d)\n" , - acpi_gbl_FADT.month_alarm); - acpi_gbl_FADT.month_alarm =0 ; - } - - cmos_rtc.day_alrm = acpi_gbl_FADT.day_alarm; - cmos_rtc.mon_alrm = acpi_gbl_FADT.month_alarm; - cmos_rtc.century = acpi_gbl_FADT.century; - -if (acpi_gbl_FADT.flags &ACPI_FADT_S4_RTC_WAKE ) -dev_info (dev,"RTC can wake from S4\n" ); - -/* RTC always wakes from S1/S2/S3, and often S4/STD */ -device_init_wakeup (dev,1 ); -} - -static void cmos_check_acpi_rtc_status (struct device *dev, -unsigned char *rtc_control) -{ -struct cmos_rtc *cmos =dev_get_drvdata (dev); -acpi_event_status rtc_status; -acpi_status status; - -if (acpi_gbl_FADT.flags &ACPI_FADT_FIXED_RTC ) -return ; - - status =acpi_get_event_status (ACPI_EVENT_RTC , &rtc_status); -if (ACPI_FAILURE (status)) { -dev_err (dev,"Could not get RTC status\n" ); - }else if (rtc_status &ACPI_EVENT_FLAG_SET ) { -unsigned char mask; - *rtc_control &= ~RTC_AIE ; -CMOS_WRITE (*rtc_control,RTC_CONTROL ); - mask =CMOS_READ (RTC_INTR_FLAGS ); -rtc_update_irq (cmos->rtc,1 , mask); - } -} - -#else - -static void cmos_wake_setup (struct device *dev) -{ -} - -static void cmos_check_acpi_rtc_status (struct device *dev, -unsigned char *rtc_control) -{ -} - -static void rtc_wake_setup (struct device *dev) -{ -} -#endif -#ifdef CONFIG_PNP #include <linux/pnp.h>
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 545/731 rtc: cmos: Rename ACPI-related functions
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit d13e9ad9f5146f066a5c5a1cc993d09e4fb21ead ]
The names of rtc_wake_setup() and cmos_wake_setup() don't indicate that these functions are ACPI-related, which is the case, and the former doesn't really reflect the role of the function.
Rename them to acpi_rtc_event_setup() and acpi_cmos_wake_setup(), respectively, to address this shortcoming.
No intentional functional impact.
Stable-dep-of: 83ebb7b3036d ("rtc: cmos: Disable ACPI RTC event on removal")
--- drivers/rtc/rtc-cmos.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/rtc-cmos.c +6 -6
@@ -784,7 +784,7 @@ static u32 rtc_handler(void *context)return ACPI_INTERRUPT_HANDLED ; } -static void rtc_wake_setup (struct device *dev) +static void acpi_rtc_event_setup (struct device *dev) {if (acpi_disabled)return ;
@@ -828,7 +828,7 @@ static void use_acpi_alarm_quirks(void)static inline void use_acpi_alarm_quirks (void ) { }#endif -static void cmos_wake_setup (struct device *dev) +static void acpi_cmos_wake_setup (struct device *dev) {if (acpi_disabled)return ;
@@ -880,11 +880,11 @@ static void cmos_check_acpi_rtc_status(struct device *dev,#else /* !CONFIG_ACPI */ -static inline void rtc_wake_setup (struct device *dev) +static inline void acpi_rtc_event_setup (struct device *dev) { } -static inline void cmos_wake_setup (struct device *dev) +static inline void acpi_cmos_wake_setup (struct device *dev) { }
@@ -986,7 +986,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) cmos_rtc.wake_off = info->wake_off; } }else { -cmos_wake_setup (dev); +acpi_cmos_wake_setup (dev); }if (cmos_rtc.day_alrm >=128 )
@@ -1091,7 +1091,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)* the ACPI RTC fixed event. */ if (!info) -rtc_wake_setup (dev); +acpi_rtc_event_setup (dev); dev_info(dev, "%s%s, %d bytes nvram%s\n", !is_valid_irq(rtc_irq) ? "no alarms" :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 546/731 rtc: cmos: Disable ACPI RTC event on removal
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 83ebb7b3036d151ee39a4a752018665648fc3bd4 ]
Make cmos_do_remove() drop the ACPI RTC fixed event handler so as to prevent it from operating on stale data in case the event triggers after driver removal.
--- drivers/rtc/rtc-cmos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/rtc/rtc-cmos.c +15 -0
@@ -798,6 +798,14 @@ static void acpi_rtc_event_setup(struct device *dev)acpi_disable_event (ACPI_EVENT_RTC ,0 ); } +static void acpi_rtc_event_cleanup (void ) +{ +if (acpi_disabled) +return ; + +acpi_remove_fixed_event_handler (ACPI_EVENT_RTC , rtc_handler); +} +static void rtc_wake_on (struct device *dev) {acpi_clear_event (ACPI_EVENT_RTC );
@@ -884,6 +892,10 @@ static inline void acpi_rtc_event_setup(struct device *dev) { } +static inline void acpi_rtc_event_cleanup (void ) +{ +} +static inline void acpi_cmos_wake_setup (struct device *dev) { }
@@ -1138,6 +1150,9 @@ static void cmos_do_remove(struct device *dev)hpet_unregister_irq_handler (cmos_interrupt); } +if (!dev_get_platdata (dev)) +acpi_rtc_event_cleanup (); + cmos->rtc =NULL ; ports = cmos->iomem;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 547/731 rtc: snvs: Allow a time difference on clock register read
In reply to Greg Kroah-HartmanFrom: Stefan Eichenberger <[email protected]>
[ Upstream commit 0462681e207ccc44778a77b3297af728b1cf5b9f ]
On an iMX6ULL the following message appears when a wakealarm is set:
echo 0 > /sys/class/rtc/rtc1/wakealarm
rtc rtc1: Timeout trying to get valid LPSRT Counter read
This does not always happen but is reproducible quite often (7 out of 10 times). The problem appears because the iMX6ULL is not able to read the registers within one 32kHz clock cycle which is the base clock of the RTC. Therefore, this patch allows a difference of up to 320 cycles (10ms). 10ms was chosen to be big enough even on systems with less cpu power (e.g. iMX6ULL). According to the reference manual a difference is fine:
- If the two consecutive reads are similar, the value is correct. The values have to be similar, not equal.
--- drivers/rtc/rtc-snvs.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/rtc/rtc-snvs.c +14 -2
@@ -32,6 +32,14 @@#define SNVS_LPPGDR_INIT 0x41736166#define CNTR_TO_SECS_SH 15 +/* The maximum RTC clock cycles that are allowed to pass between two +* consecutive clock counter register reads. If the values are corrupted a +* bigger difference is expected. The RTC frequency is 32kHz. With 320 cycles +* we end at 10ms which should be enough for most cases. If it once takes +* longer than expected we do a retry. +*/ +#define MAX_RTC_READ_DIFF_CYCLES 320 +struct snvs_rtc_data {struct rtc_device *rtc;struct regmap *regmap;
@@ -56,6 +64,7 @@ static u64 rtc_read_lpsrt(struct snvs_rtc_data *data)static u32 rtc_read_lp_counter (struct snvs_rtc_data *data) {u64 read1, read2; +s64 diff;unsigned int timeout =100 ;/* As expected, the registers might update between the read of the LSB
@@ -66,7 +75,8 @@ static u32 rtc_read_lp_counter(struct snvs_rtc_data *data)do { read2 = read1; read1 =rtc_read_lpsrt (data); - }while (read1 != read2 && --timeout); + diff = read1 - read2; + }while (((diff <0 ) || (diff >MAX_RTC_READ_DIFF_CYCLES )) && --timeout);if (!timeout)dev_err (&data->rtc->dev,"Timeout trying to get valid LPSRT Counter read\n" );
@@ -78,13 +88,15 @@ static u32 rtc_read_lp_counter(struct snvs_rtc_data *data)static int rtc_read_lp_counter_lsb (struct snvs_rtc_data *data,u32 *lsb) {u32 count1, count2; +s32 diff;unsigned int timeout =100 ;regmap_read (data->regmap, data->offset +SNVS_LPSRTCLR , &count1);do { count2 = count1;regmap_read (data->regmap, data->offset +SNVS_LPSRTCLR , &count1); - }while (count1 != count2 && --timeout); + diff = count1 - count2; + }while (((diff <0 ) || (diff >MAX_RTC_READ_DIFF_CYCLES )) && --timeout);if (!timeout) {dev_err (&data->rtc->dev,"Timeout trying to get valid LPSRT Counter read\n" );return -ETIMEDOUT ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 548/731 rtc: pcf85063: Fix reading alarm
In reply to Greg Kroah-HartmanFrom: Alexander Stein <[email protected]>
[ Upstream commit a6ceee26fd5ed9b5bd37322b1ca88e4548cee4a3 ]
If the alarms are disabled the topmost bit (AEN_*) is set in the alarm registers. This is also interpreted in BCD number leading to this warning:
rtc rtc0: invalid alarm value: 2022-09-21T80:80:80
Fix this by masking alarm enabling and reserved bits.
--- drivers/rtc/rtc-pcf85063.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pcf85063.c +4 -4
@@ -167,10 +167,10 @@ static int pcf85063_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)if (ret)return ret; - alrm->time.tm_sec =bcd2bin (buf[0 ]); - alrm->time.tm_min =bcd2bin (buf[1 ]); - alrm->time.tm_hour =bcd2bin (buf[2 ]); - alrm->time.tm_mday =bcd2bin (buf[3 ]); + alrm->time.tm_sec =bcd2bin (buf[0 ] &0x7f ); + alrm->time.tm_min =bcd2bin (buf[1 ] &0x7f ); + alrm->time.tm_hour =bcd2bin (buf[2 ] &0x3f ); + alrm->time.tm_mday =bcd2bin (buf[3 ] &0x3f ); ret =regmap_read (pcf85063->regmap,PCF85063_REG_CTRL2 , &val);if (ret)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 549/731 iommu/amd: Fix pci device refcount leak in ppr_notifier()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 6cf0981c2233f97d56938d9d61845383d6eb227c ]
As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it before returning from ppr_notifier() to avoid refcount leak.
--- drivers/iommu/amd/iommu_v2.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/amd/iommu_v2.c +1 -0
@@ -588,6 +588,7 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data)put_device_state (dev_state); out: +pci_dev_put (pdev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 550/731 iommu/fsl_pamu: Fix resource leak in fsl_pamu_probe()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 73f5fc5f884ad0c5f7d57f66303af64f9f002526 ]
The fsl_pamu_probe() returns directly when create_csd() failed, leaving irq and memories unreleased.
Fix by jumping to error if create_csd() returns error.
--- drivers/iommu/fsl_pamu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/fsl_pamu.c +1 -1
@@ -865,7 +865,7 @@ static int fsl_pamu_probe(struct platform_device *pdev) ret =create_csd (ppaact_phys, mem_size, csd_port_id);if (ret) {dev_err (dev,"could not create coherence subdomain\n" ); -return ret; + goto error; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 551/731 macintosh: fix possible memory leak in macio_add_one_device()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 5ca86eae55a2f006e6c1edd2029b2cacb6979515 ]
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically. It needs to be freed when of_device_register() fails. Call put_device() to give up the reference that's taken in device_initialize(), so that it can be freed in kobject_cleanup() when the refcount hits 0.
macio device is freed in macio_release_dev(), so the kfree() can be removed.
--- drivers/macintosh/macio_asic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/macio_asic.c +1 -1
@@ -423,7 +423,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,if (of_device_register (&dev->ofdev) !=0 ) {printk (KERN_DEBUG "macio: device registration error for %s!\n" ,dev_name (&dev->ofdev.dev)); -kfree (dev); +put_device (&dev->ofdev.dev);return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 552/731 macintosh/macio-adb: check the return value of ioremap()
In reply to Greg Kroah-HartmanFrom: Xie Shaowen <[email protected]>
[ Upstream commit dbaa3105736d4d73063ea0a3b01cd7fafce924e6 ]
The function ioremap() in macio_init() can fail, so its return value should be checked.
--- drivers/macintosh/macio-adb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/macintosh/macio-adb.c +4 -0
@@ -105,6 +105,10 @@ int macio_init(void)return -ENXIO ; } adb =ioremap (r.start,sizeof (struct adb_regs )); +if (!adb) { +of_node_put (adbs); +return -ENOMEM ; + }out_8 (&adb->ctrl.r,0 );out_8 (&adb->intr.r,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 553/731 powerpc/52xx: Fix a resource leak in an error handling path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 5836947613ef33d311b4eff6a32d019580a214f5 ]
The error handling path of mpc52xx_lpbfifo_probe() has a request_irq() that is not balanced by a corresponding free_irq().
Add the missing call, as already done in the remove function.
--- arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c +1 -0
@@ -530,6 +530,7 @@ static int mpc52xx_lpbfifo_probe(struct platform_device *op) err_bcom_rx_irq:bcom_gen_bd_rx_release (lpbfifo.bcom_rx_task); err_bcom_rx: +free_irq (lpbfifo.irq, &lpbfifo); err_irq:iounmap (lpbfifo.regs); lpbfifo.regs =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 554/731 cxl: Fix refcount leak in cxl_calc_capp_routing
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 1d09697ff22908ae487fc8c4fbde1811732be523 ]
of_get_next_parent() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. This function only calls of_node_put() in normal path, missing it in the error path.
Add missing of_node_put() to avoid refcount leak.
--- drivers/misc/cxl/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/cxl/pci.c +1 -0
@@ -387,6 +387,7 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid, rc =get_phb_index (np, phb_index);if (rc) {pr_err ("cxl: invalid phb index\n" ); +of_node_put (np);return rc; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 555/731 powerpc/xmon: Fix -Wswitch-unreachable warning in bpt_cmds
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
[ Upstream commit 1c4a4a4c8410be4a231a58b23e7a30923ff954ac ]
When building with automatic stack variable initialization, GCC 12 complains about variables defined outside of switch case statements. Move the variable into the case that uses it, which silences the warning:
arch/powerpc/xmon/xmon.c: In function ‘bpt_cmds’:arch/powerpc/xmon/xmon.c:1529:13: warning: statement will never be executed [-Wswitch-unreachable]
1529 | int mode;
| ^~~~--- arch/powerpc/xmon/xmon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/powerpc/xmon/xmon.c +4 -3
@@ -1528,9 +1528,9 @@ bpt_cmds(void) cmd =inchar ();switch (cmd) { -static const char badaddr[] ="Only kernel addresses are permitted for breakpoints\n" ; -int mode; -case 'd' :/* bd - hardware data breakpoint */ +case 'd' : {/* bd - hardware data breakpoint */ +static const char badaddr[] ="Only kernel addresses are permitted for breakpoints\n" ; +int mode;if (xmon_is_ro) {printf (xmon_ro_msg);break ;
@@ -1563,6 +1563,7 @@ bpt_cmds(void)force_enable_xmon ();break ; + }case 'i' :/* bi - hardware instr breakpoint */ if (xmon_is_ro) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 556/731 powerpc/xive: add missing iounmap() in error path in xive_spapr_populate_irq_data()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8b49670f3bb3f10cd4d5a6dca17f5a31b173ecdc ]
If remapping 'data->trig_page' fails, the 'data->eoi_mmio' need be unmapped before returning from xive_spapr_populate_irq_data().
--- arch/powerpc/sysdev/xive/spapr.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/sysdev/xive/spapr.c +1 -0
@@ -437,6 +437,7 @@ static int xive_spapr_populate_irq_data(u32 hw_irq, struct xive_irq_data *data) data->trig_mmio =ioremap (data->trig_page,1u << data->esb_shift);if (!data->trig_mmio) { +iounmap (data->eoi_mmio);pr_err ("Failed to map trigger page for irq 0x%x\n" , hw_irq);return -ENOMEM ; }
Signature · 1 line
2.35.1