mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Check for valid usbdev in _usb_read in case the device has been unplugged.
This commit is contained in:
parent
99b117be47
commit
f3093803d1
@ -2011,7 +2011,7 @@ static void rejected_inc(struct cgpu_info *cgpu, uint32_t mode)
|
||||
int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, const char *end, __maybe_unused enum usb_cmds cmd, bool readonce)
|
||||
{
|
||||
struct cg_usb_device *usbdev = cgpu->usbdev;
|
||||
bool ftdi = (usbdev->usb_type == USB_TYPE_FTDI);
|
||||
bool ftdi;
|
||||
#if DO_USB_STATS
|
||||
struct timeval tv_start;
|
||||
#endif
|
||||
@ -2027,6 +2027,11 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
|
||||
unsigned char usbbuf[USB_MAX_READ+4], *ptr;
|
||||
size_t usbbufread;
|
||||
|
||||
if (unlikely(!usbdev))
|
||||
return LIBUSB_ERROR_NO_DEVICE;
|
||||
|
||||
ftdi = (usbdev->usb_type == USB_TYPE_FTDI);
|
||||
|
||||
USBDEBUG("USB debug: _usb_read(%s (nodev=%s),ep=%d,buf=%p,bufsiz=%zu,proc=%p,timeout=%u,end=%s,cmd=%s,ftdi=%s,readonce=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), ep, buf, bufsiz, processed, timeout, end ? (char *)str_text((char *)end) : "NULL", usb_cmdname(cmd), bool_str(ftdi), bool_str(readonce));
|
||||
|
||||
if (bufsiz > USB_MAX_READ)
|
||||
|
Loading…
Reference in New Issue
Block a user