diff mbox series

[v3,12/19] libmutipath: don't use malformed uevents

Message ID 1537571127-10143-13-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series Misc Multipath patches | expand

Commit Message

Benjamin Marzinski Sept. 21, 2018, 11:05 p.m. UTC
A uevent that doesn't include the ACTION and DEVPATH fields is
malformed. It should be ignored, instead of used with those fields being
NULL.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/uevent.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Martin Wilck Oct. 1, 2018, 9:31 p.m. UTC | #1
On Fri, 2018-09-21 at 18:05 -0500, Benjamin Marzinski wrote:
> A uevent that doesn't include the ACTION and DEVPATH fields is
> malformed. It should be ignored, instead of used with those fields
> being
> NULL.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>

Reviewed-by: Martin Wilck <mwilck@suse.com>

> ---
>  libmultipath/uevent.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
> index fd8ca35..5f910e6 100644
> --- a/libmultipath/uevent.c
> +++ b/libmultipath/uevent.c
> @@ -729,6 +729,12 @@ struct uevent *uevent_from_udev_device(struct
> udev_device *dev)
>  		if (i == HOTPLUG_NUM_ENVP - 1)
>  			break;
>  	}
> +	if (!uev->devpath || ! uev->action) {
> +		udev_device_unref(dev);
> +		condlog(1, "uevent missing necessary fields");
> +		FREE(uev);
> +		return NULL;
> +	}
>  	uev->udev = dev;
>  	uev->envp[i] = NULL;
>
diff mbox series

Patch

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index fd8ca35..5f910e6 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -729,6 +729,12 @@  struct uevent *uevent_from_udev_device(struct udev_device *dev)
 		if (i == HOTPLUG_NUM_ENVP - 1)
 			break;
 	}
+	if (!uev->devpath || ! uev->action) {
+		udev_device_unref(dev);
+		condlog(1, "uevent missing necessary fields");
+		FREE(uev);
+		return NULL;
+	}
 	uev->udev = dev;
 	uev->envp[i] = NULL;