fix kernel module bugs

This commit is contained in:
Triss 2021-07-25 03:40:34 +02:00
parent 84d04e6d7e
commit 1d890a2aa2
2 changed files with 4 additions and 3 deletions

View File

@ -56,7 +56,8 @@ static ssize_t dmj_char_read(struct file *file, char *buf, size_t len, loff_t *l
if (len > INT_MAX) return -EINVAL;
ilen = (int)len;
res = dmj_transfer(dmjch->pdev, -1, DMJ_XFER_FLAGS_FILL_RECVBUF, NULL, 0, &kbuf, &ilen);
/* no flags: act like libusb read */
res = dmj_transfer(dmjch->pdev, -1, 0/*DMJ_XFER_FLAGS_FILL_RECVBUF*/, NULL, 0, &kbuf, &ilen);
if (res < 0 || ilen < 0 || !kbuf) {
if (kbuf) kfree(kbuf);
return (res >= 0) ? -EIO : ret;

View File

@ -227,7 +227,7 @@ int dmj_xfer_internal(struct dmj_dev *dmj, int cmd, int recvflags,
* will error when going beyond!). also done in 64b chunks
*/
if (!rbuf || !rbufsize || *rbufsize <= 0) return 0;
if (!rbufsize || *rbufsize <= 0) return 0;
if (recvflags & DMJ_XFER_FLAGS_FILL_RECVBUF) {
tmpbuf = kmalloc(64, GFP_KERNEL);
@ -265,7 +265,7 @@ int dmj_xfer_internal(struct dmj_dev *dmj, int cmd, int recvflags,
ret = usb_bulk_msg(dmj->usb_dev, usb_rcvbulkpipe(dmj->usb_dev, dmj->ep_in),
longbuf, *rbufsize, rbufsize, DMJ_USB_TIMEOUT);
if (ret < 0) goto err_freelong;
if (actual < 0) { ret = -EREMOTEIO; goto err_freelong; }
if (*rbufsize < 0) ret = -EREMOTEIO; goto err_freelong;
ret = 0;
*rbuf = longbuf;