Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d130367 authored by Johan Hovold's avatar Johan Hovold
Browse files

USB: serial: mos7720: fix control-message error handling



Make sure to log an error on short transfers when reading a device
register.

Also clear the provided buffer (which if often an uninitialised
automatic variable) on errors as the driver currently does not bother to
check for errors.

Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 36356a66
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -234,11 +234,16 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,

	status = usb_control_msg(usbdev, pipe, request, requesttype, value,
				     index, buf, 1, MOS_WDR_TIMEOUT);
	if (status == 1)
	if (status == 1) {
		*data = *buf;
	else if (status < 0)
	} else {
		dev_err(&usbdev->dev,
			"mos7720: usb_control_msg() failed: %d\n", status);
		if (status >= 0)
			status = -EIO;
		*data = 0;
	}

	kfree(buf);

	return status;