Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault for 'lpac driver http' when using QMI backend #174

Open
AndreySV opened this issue Dec 3, 2024 · 2 comments
Open

Segmentation fault for 'lpac driver http' when using QMI backend #174

AndreySV opened this issue Dec 3, 2024 · 2 comments

Comments

@AndreySV
Copy link

AndreySV commented Dec 3, 2024

I was just experimenting with lpac and found that is segfaults in following situation:

$ sudo env LPAC_APDU=qmi QMI_DEVICE=/dev/cdc-wdm0 LIBEUICC_DEBUG_APDU=1 ./output/lpac driver
Usage: driver <apdu|http>

$ sudo env LPAC_APDU=qmi QMI_DEVICE=/dev/cdc-wdm0 LIBEUICC_DEBUG_APDU=1 ./output/lpac driver http
Cleaning up leaked APDU channel 1375198244
Segmentation fault
@CoelacanthusHex
Copy link
Contributor

Please provide backtrace. You usually could get it via coredumpctl debug lpac.

@CoelacanthusHex
Copy link
Contributor

I have a guess: in qmi driver init code, we allocate memory for qmi_priv

qmi_priv = malloc(sizeof(struct qmi_data));

But doesn't init it with default value. So there is junk data now. When invoking lpac driver http, qmi driver doesn't do any actual thing, so it leaves junk data. When the fini function was invoked, it lookup lastChannelId field found non-zero junk data, and then tried to destroy the resource of that channel.
void qmi_cleanup(struct qmi_data *qmi_priv)
{
if (qmi_priv->lastChannelId > 0)
{
fprintf(stderr, "Cleaning up leaked APDU channel %d\n", qmi_priv->lastChannelId);
qmi_apdu_interface_logic_channel_close(NULL, qmi_priv->lastChannelId);
qmi_priv->lastChannelId = -1;
}
}

@CoelacanthusHex CoelacanthusHex changed the title Segmentation fault for 'lpac driver http' Segmentation fault for 'lpac driver http' when using QMI backend Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants