genetlink: Use string_is_terminated() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 8 Feb 2023 13:31:52 +0000 (15:31 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 10 Feb 2023 06:30:24 +0000 (22:30 -0800)
Use string_is_terminated() helper instead of cpecific memchr() call.
This shows better the intention of the call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20230208133153.22528-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/netlink/genetlink.c

index 600993c80050d30f5357200be89b9f994c13d8a6..04c4036bf4064e8719dfbc8efd2f570bdffdd3a3 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
 #include <linux/skbuff.h>
 #include <linux/mutex.h>
 #include <linux/bitmap.h>
@@ -457,7 +457,7 @@ static int genl_validate_assign_mc_groups(struct genl_family *family)
 
                if (WARN_ON(grp->name[0] == '\0'))
                        return -EINVAL;
-               if (WARN_ON(memchr(grp->name, '\0', GENL_NAMSIZ) == NULL))
+               if (WARN_ON(!string_is_terminated(grp->name, GENL_NAMSIZ)))
                        return -EINVAL;
        }