mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-09 04:16:11 +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 (FU_IS_UDEV_DEVICE (self), FALSE);
|
||||||
g_return_val_if_fail (request != 0x0, FALSE);
|
g_return_val_if_fail (request != 0x0, FALSE);
|
||||||
g_return_val_if_fail (buf != NULL, 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);
|
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);
|
rc_tmp = ioctl (priv->fd, request, buf);
|
||||||
if (rc != NULL)
|
if (rc != NULL)
|
||||||
*rc = rc_tmp;
|
*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 (FU_IS_UDEV_DEVICE (self), FALSE);
|
||||||
g_return_val_if_fail (buf != NULL, 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);
|
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
|
#ifdef HAVE_PWRITE
|
||||||
if (pread (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
if (pread (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -1434,9 +1454,19 @@ fu_udev_device_pwrite_full (FuUdevDevice *self, goffset port,
|
|||||||
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
|
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
|
|
||||||
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), FALSE);
|
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);
|
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
|
#ifdef HAVE_PWRITE
|
||||||
if (pwrite (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
if (pwrite (priv->fd, buf, bufsz, port) != (gssize) bufsz) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
|
Loading…
Reference in New Issue
Block a user