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: <ZBAjNlv+NbC2Le0v@ye-NUC7i7DNHE>
Date:   Tue, 14 Mar 2023 15:33:10 +0800
From:   "Ye, Xiang" <xiang.ye@...el.com>
To:     Andi Shyti <andi.shyti@...nel.org>
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 Andi,

Thanks for the review.
On Mon, Mar 13, 2023 at 05:21:46PM +0100, Andi Shyti wrote:
> 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.
Ok, got it.
> 
> [...]
> 
> > +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?
DFU mode is used for updating LJCA device Firmware.
We have a Documentation/ABI/testing/sysfs-bus-usb-devices-ljca in patch
5 of this patch series. It has information about the entry. Maybe it
should be go after this patch (patch 2/5).
> 
> > +
> > +	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?
We have a patch (patch 5 of this series) adding some Documentation/ABI/
entries to specify the correct value for each entry.

> 
> > +
> > +	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()
Got it. Thanks.

--
Thanks
Ye Xiang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ