lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWYqCDpceft22AT0dFkuw877JiHA1NkToFzehARu+fL6Q@mail.gmail.com>
Date:	Mon, 15 Dec 2014 12:13:19 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
	Felipe Balbi <balbi@...com>
Cc:	USB list <linux-usb@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: usb: gadget: hid: add configfs support

On Mon, Dec 15, 2014 at 12:06 AM, Linux Kernel Mailing List
<linux-kernel@...r.kernel.org> wrote:
> Gitweb:     http://git.kernel.org/linus/;a=commit;h=21a9476a7ba847e413bf1c144d7c614532aed6dd
> Commit:     21a9476a7ba847e413bf1c144d7c614532aed6dd
> Parent:     5ca8d3ec9970f4798e68bd21a9d44db3d0ff4da7
> Refname:    refs/heads/master
> Author:     Andrzej Pietrasiewicz <andrzej.p@...sung.com>
> AuthorDate: Thu Nov 6 11:12:03 2014 +0100
> Committer:  Felipe Balbi <balbi@...com>
> CommitDate: Thu Nov 6 16:18:19 2014 -0600
>
>     usb: gadget: hid: add configfs support
>
>     Make the hid function available for gadgets composed with configfs.
>

> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c

> +
> +#define F_HID_OPT(name, prec, limit)                                   \
> +static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
> +{                                                                      \
> +       int result;                                                     \
> +                                                                       \
> +       mutex_lock(&opts->lock);                                        \
> +       result = sprintf(page, "%d\n", opts->name);                     \
> +       mutex_unlock(&opts->lock);                                      \
> +                                                                       \
> +       return result;                                                  \
> +}                                                                      \
> +                                                                       \
> +static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts,      \
> +                                        const char *page, size_t len)  \
> +{                                                                      \
> +       int ret;                                                        \
> +       u##prec num;                                                    \
> +                                                                       \
> +       mutex_lock(&opts->lock);                                        \
> +       if (opts->refcnt) {                                             \
> +               ret = -EBUSY;                                           \
> +               goto end;                                               \
> +       }                                                               \
> +                                                                       \
> +       ret = kstrtou##prec(page, 0, &num);                             \
> +       if (ret)                                                        \
> +               goto end;                                               \
> +                                                                       \
> +       if (num > limit) {                                              \
> +               ret = -EINVAL;                                          \
> +               goto end;                                               \
> +       }                                                               \
> +       opts->name = num;                                               \
> +       ret = len;                                                      \
> +                                                                       \
> +end:                                                                   \
> +       mutex_unlock(&opts->lock);                                      \
> +       return ret;                                                     \
> +}                                                                      \
> +                                                                       \
> +static struct f_hid_opts_attribute f_hid_opts_##name =                 \
> +       __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
> +                       f_hid_opts_##name##_store)
> +
> +F_HID_OPT(subclass, 8, 255);
> +F_HID_OPT(protocol, 8, 255);
> +F_HID_OPT(report_length, 16, 65536);

While all three of the above lines trigger a (false positive) compiler warning:

warning: comparison is always false due to limited range of data type

it's a bit sloppy to use "2^8-1" for the first two limits, and "2^16"
(without -1) for
the third limit.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ