mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 19:48:47 +00:00
trivial: Set the GError when calling ioctl() on an un-opened device
I've not yet worked out the real bug, but it was unexpected to crash the daemon when open failed, rather than for a critical misuse of the API.
This commit is contained in:
parent
14c0f7c80e
commit
0b6c67a3e3
@ -1328,9 +1328,19 @@ fu_udev_device_ioctl (FuUdevDevice *self,
|
||||
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), FALSE);
|
||||
g_return_val_if_fail (request != 0x0, FALSE);
|
||||
g_return_val_if_fail (buf != NULL, FALSE);
|
||||
g_return_val_if_fail (priv->fd > 0, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* not open! */
|
||||
if (priv->fd == 0) {
|
||||
g_set_error (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INTERNAL,
|
||||
"%s [%s] has not been opened",
|
||||
fu_device_get_id (FU_DEVICE (self)),
|
||||
fu_device_get_name (FU_DEVICE (self)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rc_tmp = ioctl (priv->fd, request, buf);
|
||||
if (rc != NULL)
|
||||
*rc = rc_tmp;
|
||||
@ -1389,9 +1399,19 @@ fu_udev_device_pread_full (FuUdevDevice *self, goffset port,
|
||||
|
||||
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), FALSE);
|
||||
g_return_val_if_fail (buf != NULL, FALSE);
|
||||
g_return_val_if_fail (priv->fd > 0, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* not open! */
|
||||
if (priv->fd == 0) {
|
||||
g_set_error (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INTERNAL,
|
||||
"%s [%s] has not been opened",
|
||||
fu_device_get_id (FU_DEVICE (self)),
|
||||
fu_device_get_name (FU_DEVICE (self)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PWRITE
|
||||
if (pread (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
||||
g_set_error (error,
|
||||
@ -1434,9 +1454,19 @@ fu_udev_device_pwrite_full (FuUdevDevice *self, goffset port,
|
||||
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
|
||||
|
||||
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), FALSE);
|
||||
g_return_val_if_fail (priv->fd > 0, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* not open! */
|
||||
if (priv->fd == 0) {
|
||||
g_set_error (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INTERNAL,
|
||||
"%s [%s] has not been opened",
|
||||
fu_device_get_id (FU_DEVICE (self)),
|
||||
fu_device_get_name (FU_DEVICE (self)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PWRITE
|
||||
if (pwrite (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
||||
g_set_error (error,
|
||||
|
Loading…
Reference in New Issue
Block a user