Revert "UPSTREAM: usb: gadget: f_uac2: validate input parameters"

This reverts commit 5abbf39685 as it is
coming in through the 5.10.36 LTS release and causes a build error when
that is merged into here.

Bug: 187332233
Cc: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ibd70fc1b1260bdf1da5070e80df3066606a1d45e
This commit is contained in:
Greg Kroah-Hartman 2021-05-13 09:11:28 +02:00
commit 345f1259a0

View file

@ -14,9 +14,6 @@
#include "u_audio.h"
#include "u_uac2.h"
/* UAC2 spec: 4.1 Audio Channel Cluster Descriptor */
#define UAC2_CHANNEL_MASK 0x07FFFFFF
/*
* The driver implements a simple UAC_2 topology.
* USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture
@ -680,36 +677,6 @@ static void setup_descriptor(struct f_uac2_opts *opts)
setup_headers(opts, ss_audio_desc, USB_SPEED_SUPER);
}
static int afunc_validate_opts(struct g_audio *agdev, struct device *dev)
{
struct f_uac2_opts *opts = g_audio_to_uac2_opts(agdev);
if (!opts->p_chmask && !opts->c_chmask) {
dev_err(dev, "Error: no playback and capture channels\n");
return -EINVAL;
} else if (opts->p_chmask & ~UAC2_CHANNEL_MASK) {
dev_err(dev, "Error: unsupported playback channels mask\n");
return -EINVAL;
} else if (opts->c_chmask & ~UAC2_CHANNEL_MASK) {
dev_err(dev, "Error: unsupported capture channels mask\n");
return -EINVAL;
} else if ((opts->p_ssize < 1) || (opts->p_ssize > 4)) {
dev_err(dev, "Error: incorrect playback sample size\n");
return -EINVAL;
} else if ((opts->c_ssize < 1) || (opts->c_ssize > 4)) {
dev_err(dev, "Error: incorrect capture sample size\n");
return -EINVAL;
} else if (!opts->p_srate) {
dev_err(dev, "Error: incorrect playback sampling rate\n");
return -EINVAL;
} else if (!opts->c_srate) {
dev_err(dev, "Error: incorrect capture sampling rate\n");
return -EINVAL;
}
return 0;
}
static int
afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
{
@ -718,13 +685,11 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
struct usb_composite_dev *cdev = cfg->cdev;
struct usb_gadget *gadget = cdev->gadget;
struct device *dev = &gadget->dev;
struct f_uac2_opts *uac2_opts = g_audio_to_uac2_opts(agdev);
struct f_uac2_opts *uac2_opts;
struct usb_string *us;
int ret;
ret = afunc_validate_opts(agdev, dev);
if (ret)
return ret;
uac2_opts = container_of(fn->fi, struct f_uac2_opts, func_inst);
us = usb_gstrings_attach(cdev, fn_strings, ARRAY_SIZE(strings_fn));
if (IS_ERR(us))