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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230313162146.eag5z6micbpczbt2@intel.intel>
Date:   Mon, 13 Mar 2023 17:21:46 +0100
From:   Andi Shyti <andi.shyti@...nel.org>
To:     Ye Xiang <xiang.ye@...el.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        Matthias Kaehlcke <mka@...omium.org>,
        Lee Jones <lee@...nel.org>, Wolfram Sang <wsa@...nel.org>,
        Tyrone Ting <kfting@...oton.com>,
        Mark Brown <broonie@...nel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <brgl@...ev.pl>, linux-usb@...r.kernel.org,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-spi@...r.kernel.org, linux-gpio@...r.kernel.org,
        srinivas.pandruvada@...el.com, heikki.krogerus@...ux.intel.com,
        andriy.shevchenko@...ux.intel.com, sakari.ailus@...ux.intel.com,
        zhifeng.wang@...el.com, wentong.wu@...el.com, lixu.zhang@...el.com
Subject: Re: [PATCH v5 1/5] usb: Add support for Intel LJCA device

Hi Ye,

On top of what Greg has already said, few things from my side
through the lines.

[...]

> +static int ljca_mng_link(struct ljca_dev *dev, struct ljca_stub *stub)
> +{
> +	int ret;
> +
> +	ret = ljca_mng_reset_handshake(stub);
> +	if (ret)
> +		return ret;
> +
> +	/* try to enum all the stubs */
> +	ljca_mng_enum_gpio(stub);
> +	ljca_mng_enum_i2c(stub);
> +	ljca_mng_enum_spi(stub);

We are ignoring here the return value. So either make the
whole function call chain to be void or please check the return
values here.

[...]

> +static ssize_t ljca_enable_dfu_store(struct device *dev, struct device_attribute *attr,
> +				     const char *buf, size_t count)
> +{
> +	struct usb_interface *intf = to_usb_interface(dev);
> +	struct ljca_dev *ljca_dev = usb_get_intfdata(intf);
> +	struct ljca_stub *mng_stub = ljca_stub_find(ljca_dev, LJCA_MNG_STUB);
> +	bool enable;
> +	int ret;
> +
> +	ret = kstrtobool(buf, &enable);
> +	if (ret)
> +		return ret;
> +
> +	if (enable) {
> +		ret = ljca_mng_set_dfu_mode(mng_stub);
> +		if (ret)
> +			return ret;
> +	}

What is the DFU mode?
Is it an operational mode?
Do we enter and exit from it?
Does the device leave this mode on its own?
What if I write twice in a raw enable?
Can I check if I am in DFU mode or not?

Would you mind adding some comments here?

> +
> +	return count;
> +}
> +static DEVICE_ATTR_WO(ljca_enable_dfu);
> +
> +static ssize_t ljca_trace_level_store(struct device *dev, struct device_attribute *attr,
> +				      const char *buf, size_t count)
> +{
> +	struct usb_interface *intf = to_usb_interface(dev);
> +	struct ljca_dev *ljca_dev = usb_get_intfdata(intf);
> +	struct ljca_stub *diag_stub = ljca_stub_find(ljca_dev, LJCA_DIAG_STUB);
> +	u8 level;
> +	int ret;
> +
> +	if (kstrtou8(buf, 0, &level))
> +		return -EINVAL;
> +
> +	ret = ljca_diag_set_trace_level(diag_stub, level);
> +	if (ret)
> +		return ret;

do we need any range check for the levels? What happens if I do:

echo "I am too cool" > /sys/.../ljca_trace_level

As there were questions here, would you mind adding some comments
so that the next reader won't make the same questions?

> +
> +	return count;
> +}
> +static DEVICE_ATTR_WO(ljca_trace_level);

[...]

> +static int ljca_probe(struct usb_interface *intf, const struct usb_device_id *id)
> +{
> +	struct ljca_dev *dev;
> +	struct usb_endpoint_descriptor *bulk_in, *bulk_out;
> +	int ret;
> +
> +	/* allocate memory for our device state and initialize it */
> +	dev = kzalloc(sizeof(*dev), GFP_KERNEL);

devm_kzalloc()

Thanks,
Andi

> +	if (!dev)
> +		return -ENOMEM;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ