[libvirt] [PATCH v2] node_device: Check return value for udev_new()

Marc Hartmayer posted 1 patch 147 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170210094444.23108-1-mhartmay@linux.vnet.ibm.com
src/node_device/node_device_udev.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

[libvirt] [PATCH v2] node_device: Check return value for udev_new()

Posted by Marc Hartmayer 147 weeks ago
The comment was actually wrong as
https://www.freedesktop.org/software/systemd/man/udev_new.html#
mentions that on failure NULL is returned.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
---
 src/node_device/node_device_udev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 4b81312..693194d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1491,13 +1491,12 @@ static int nodeStateInitialize(bool privileged,
     if (udevPCITranslateInit(privileged) < 0)
         goto cleanup;
 
-    /*
-     * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
-     *
-     * indicates no return value other than success, so we don't check
-     * its return value.
-     */
     udev = udev_new();
+    if (!udev) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("failed to create udev context"));
+        goto cleanup;
+    }
 #if HAVE_UDEV_LOGGING
     /* cast to get rid of missing-format-attribute warning */
     udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] node_device: Check return value for udev_new()

Posted by Martin Kletzander 146 weeks ago
On Fri, Feb 10, 2017 at 10:44:44AM +0100, Marc Hartmayer wrote:
>The comment was actually wrong as
>https://www.freedesktop.org/software/systemd/man/udev_new.html#
>mentions that on failure NULL is returned.
>
>Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>---
> src/node_device/node_device_udev.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>

ACK, sorry for the late review, I added one sentence to the commit
message and pushed it.  Thanks.

>diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
>index 4b81312..693194d 100644
>--- a/src/node_device/node_device_udev.c
>+++ b/src/node_device/node_device_udev.c
>@@ -1491,13 +1491,12 @@ static int nodeStateInitialize(bool privileged,
>     if (udevPCITranslateInit(privileged) < 0)
>         goto cleanup;
>
>-    /*
>-     * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
>-     *
>-     * indicates no return value other than success, so we don't check
>-     * its return value.
>-     */
>     udev = udev_new();
>+    if (!udev) {
>+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+                       _("failed to create udev context"));
>+        goto cleanup;
>+    }
> #if HAVE_UDEV_LOGGING
>     /* cast to get rid of missing-format-attribute warning */
>     udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
>--
>2.5.5
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] node_device: Check return value for udev_new()

Posted by Marc Hartmayer 146 weeks ago
On Mon, Feb 20, 2017 at 02:48 PM +0100, Martin Kletzander <mkletzan@redhat.com> wrote:
> On Fri, Feb 10, 2017 at 10:44:44AM +0100, Marc Hartmayer wrote:
>>The comment was actually wrong as
>>https://www.freedesktop.org/software/systemd/man/udev_new.html#
>>mentions that on failure NULL is returned.
>>
>>Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>>---
>> src/node_device/node_device_udev.c | 11 +++++------
>> 1 file changed, 5 insertions(+), 6 deletions(-)
>>
>
> ACK, sorry for the late review, I added one sentence to the commit
> message and pushed it.  Thanks.

Thanks!

>
>>diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
>>index 4b81312..693194d 100644
>>--- a/src/node_device/node_device_udev.c
>>+++ b/src/node_device/node_device_udev.c
>>@@ -1491,13 +1491,12 @@ static int nodeStateInitialize(bool privileged,
>>     if (udevPCITranslateInit(privileged) < 0)
>>         goto cleanup;
>>
>>-    /*
>>-     * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
>>-     *
>>-     * indicates no return value other than success, so we don't check
>>-     * its return value.
>>-     */
>>     udev = udev_new();
>>+    if (!udev) {
>>+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>>+                       _("failed to create udev context"));
>>+        goto cleanup;
>>+    }
>> #if HAVE_UDEV_LOGGING
>>     /* cast to get rid of missing-format-attribute warning */
>>     udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
>>--
>>2.5.5
>>
>>--
>>libvir-list mailing list
>>libvir-list@redhat.com
>>https://www.redhat.com/mailman/listinfo/libvir-list
-- 
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list