From 23221b4919823b642026aea117c1228c152d9d57 Mon Sep 17 00:00:00 2001 From: Belgin Stirbu Date: Fri, 4 Feb 2022 10:15:57 +0100 Subject: devices: generic: generic_poll: Fix unitialized pollfd struct fields. Before that fix, ipc-modem would sometimes hang in generic_poll. Sometimes it would hang a lot and stop hanging after a reboot of the Galaxy SIII (GT-I9300), and sometimes that bug was really hard to reproduce. Here is the log of when it happens. It hangs at the end: # ipc-modem start --pin=1234 --debug --call=06xxxxxxxx [I] Got SIM PIN! [I] Got call number! [I] Debug enabled [0] Starting modem on FMT client [D] ENTER generic_data_create [D] generic_data_create DONE [D] ENTER generic_boot [D] Starting generic modem boot Bus 001 Device 002: ID 1519:0020 Comneon HSIC Device Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub [D] open_android_modem_partition_by_name: Trying to open /dev/disk/by-partlabel/RADIO [D] generic_boot: Opened the RADIO partition [D] Mapped modem image data to memory [D] ENTER xmm626_kernel_linux_modem_hci_power [D] xmm626_kernel_linux_modem_hci_power: DONE [D] Turned the modem off [D] generic_boot: xmm626_kernel_linux_modem_power(NULL, 1) = 0 [D] ENTER xmm626_kernel_linux_modem_hci_power [D] xmm626_kernel_linux_modem_hci_power: DONE [D] generic_boot: xmm626_kernel_linux_modem_hci_power(client, 1) = 0 [D] Turned the modem on Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub [D] Opened modem boot device [D] Wrote ATAT in ASCII [D] Read chip id (0x16) [D] Wrote PSI header [D] Wrote PSI, CRC is 0xc8 [D] Wrote PSI CRC (0xc8) [D] Read PSI CRC ACK [D] Read PSI ACK [D] Sent XMM626 HSIC PSI [D] Wrote EBL size [D] Wrote EBL, CRC is 0xb5 [D] Wrote EBL CRC (0xb5) [D] Sent XMM626 HSIC EBL [D] Read port config [D] Sent XMM626 HSIC port config [D] Sent XMM626 HSIC SEC start [D] Sent XMM626 HSIC firmware [D] Checked nv_data path [D] Checked nv_data md5 path [D] Calculated nv_data md5: 7f6d593d706cf196f16c4ea9efdcf49f [D] Read nv_data md5: 7f6d593d706cf196f16c4ea9efdcf49f [D] Checked nv_data backup path [D] Loaded nv_data [D] Sent XMM626 HSIC nv_data [D] Sent XMM626 HSIC SEC end [D] Sent XMM626 HSIC HW reset [D] Waited for host wake [D] ENTER xmm626_kernel_linux_modem_hci_power [D] xmm626_kernel_linux_modem_hci_power: DONE [D] Turned off the modem [D] Waited for host wake [D] ENTER xmm626_kernel_linux_modem_hci_power [D] xmm626_kernel_linux_modem_hci_power: DONE [D] Turned the modem on Bus 001 Device 002: ID 1519:0020 Comneon HSIC Device Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub [D] Wait for the modem to come up again Bus 001 Device 002: ID 1519:0020 Comneon HSIC Device Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub [D] generic_boot complete [D] generic_boot DONE [D] ENTER generic_open [D] ENTER xmm626_kernel_linux_modem_open [D] xmm626_kernel_linux_modem_open: client type: FMT [D] EXIT xmm626_kernel_linux_modem_open [D] generic_open DONE [D] ENTER generic_power_on: dummy function [1] Starting modem_read_loop on FMT client [D] ENTER generic_poll [D] generic_poll: poll: 1 [D] ENTER generic_read [D] generic_read DONE [D] xmm626_kernel_smdk4412_fmt_recv: Received FMT message [D] xmm626_kernel_smdk4412_fmt_recv: Message: aseq=0xff, command=IPC_DISP_RSSI_INFO, type=IPC_TYPE_NOTI, size=1 [D] ================================= IPC FMT data ================================= [D] [0000] 45 E [D] ================================================================================ [D] ENTER generic_poll With the current code, only the 'fd' field of the pollfd 'fd' variable is set, so events and revents are unitialized. And since it blocks at generic_poll, this commit can hopefuly fix that issue. Signed-off-by: Belgin Stirbu GNUtoo: commit message Signed-off-by: Denis 'GNUtoo' Carikli --- samsung-ipc/devices/generic/generic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samsung-ipc/devices/generic/generic.c b/samsung-ipc/devices/generic/generic.c index 31fbbea..0cf25d9 100644 --- a/samsung-ipc/devices/generic/generic.c +++ b/samsung-ipc/devices/generic/generic.c @@ -692,6 +692,8 @@ int generic_poll(__attribute__((unused)) struct ipc_client *client, int rc; struct pollfd fd; + memset(&fd, 0, sizeof(fd)); + #if GENERIC_DEBUG ipc_client_log(client, "ENTER %s", __func__); #endif -- cgit v1.2.3