lkml.org 
[lkml]   [2020]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 17/22] drivers/base: Make device_find_child_by_name() compatible with sysfs inputs
On Sun, Jul 12, 2020 at 09:27:37AM -0700, Dan Williams wrote:
> Use sysfs_streq() in device_find_child_by_name() to allow it to use a
> sysfs input string that might contain a trailing newline.
>
> The other "device by name" interfaces,
> {bus,driver,class}_find_device_by_name(), already account for sysfs
> strings.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> drivers/base/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 67d39a90b45c..5d31b962c898 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3078,7 +3078,7 @@ struct device *device_find_child_by_name(struct device *parent,
>
> klist_iter_init(&parent->p->klist_children, &i);
> while ((child = next_device(&i)))
> - if (!strcmp(dev_name(child), name) && get_device(child))
> + if (sysfs_streq(dev_name(child), name) && get_device(child))

Who wants to call this function with a name passed from userspace?

Not objecting to it, just curious...

thanks,

greg k-h

\
 
 \ /
  Last update: 2020-07-12 19:11    [W:0.621 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site