core: better handle NULL spew from serial ports during probing
Observed on a generic ZTE device.
This commit is contained in:
@@ -515,6 +515,11 @@ static const char *dq_strings[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static guint8 zerobuf[32] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static void
|
||||
probed_info_free (MMPluginBaseProbedInfo *info)
|
||||
{
|
||||
@@ -535,6 +540,13 @@ port_buffer_full (MMSerialPort *port, GByteArray *buffer, gpointer user_data)
|
||||
size_t iter_len;
|
||||
int i;
|
||||
|
||||
/* Some devices (observed on a ZTE branded "QUALCOMM INCORPORATED" model
|
||||
* "154") spew NULLs from some ports.
|
||||
*/
|
||||
if ( (buffer->len >= sizeof (zerobuf))
|
||||
&& (memcmp (buffer->data, zerobuf, sizeof (zerobuf)) == 0))
|
||||
goto stop_probing;
|
||||
|
||||
/* Check for an immediate disqualification response. There are some
|
||||
* ports (Option Icera-based chipsets have them, as do Qualcomm Gobi
|
||||
* devices before their firmware is loaded) that just shouldn't be
|
||||
@@ -551,15 +563,18 @@ port_buffer_full (MMSerialPort *port, GByteArray *buffer, gpointer user_data)
|
||||
for (i = 0; i < buffer->len - iter_len; i++) {
|
||||
if (!memcmp (&buffer->data[i], *iter, iter_len)) {
|
||||
/* Immediately close the port and complete probing */
|
||||
goto stop_probing;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
stop_probing:
|
||||
priv->probed_caps = 0;
|
||||
priv->probed_vendor = NULL;
|
||||
priv->probed_product = NULL;
|
||||
mm_serial_port_close (MM_SERIAL_PORT (priv->probe_port));
|
||||
probe_complete (task);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Reference in New Issue
Block a user