Commit 8200e9da authored by John Ballance's avatar John Ballance

Resolved a couple of obscure null pointer errors

Detail:
  A misbehaving USB SDcard adaptor caused unexpected duplication of some
  structure free calls. Ensured this is protected
Admin:
  tested on iMx6

Version 0.25. Tagged as 'SCSISoftUSB-0_25'
parent 3ef0ad5c
/* (0.24)
/* (0.25)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.24
#define Module_MajorVersion_CMHG 0.25
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 01 Jul 2018
#define Module_Date_CMHG 13 Jul 2018
#define Module_MajorVersion "0.24"
#define Module_Version 24
#define Module_MajorVersion "0.25"
#define Module_Version 25
#define Module_MinorVersion ""
#define Module_Date "01 Jul 2018"
#define Module_Date "13 Jul 2018"
#define Module_ApplicationDate "01-Jul-18"
#define Module_ApplicationDate "13-Jul-18"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.24"
#define Module_HelpVersion "0.24 (01 Jul 2018)"
#define Module_LibraryVersionInfo "0:24"
#define Module_FullVersion "0.25"
#define Module_HelpVersion "0.25 (13 Jul 2018)"
#define Module_LibraryVersionInfo "0:25"
......@@ -161,7 +161,7 @@ bool glue_AttachDevice(my_usb_device_t *device, uint8_t *maxlun)
bool result = umass_attach_riscos(softc, &uaa, device->subclass, device->protocol);
*maxlun = softc->maxlun;
DEBUGf("AttachDevice done\n");
DEBUGf("AttachDevice done. MaxLun was %d\n",softc->maxlun);
return result;
}
......@@ -317,7 +317,13 @@ void glue_ResetDevice(my_usb_device_t *device, int reason)
*****************************************************************************/
_kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t data_direction, const char *control_block, size_t control_block_length, scatter_entry_t *scatter_list, size_t transfer_length, void (*callback)(void), void *callback_pw, void *callback_wp)
{
DEBUGf("\nDoCommand\n");
DEBUGf("\nDoCommand device %p lun %x\n",device,lun);
if(lun > device->maxlun )
{
DEBUGf("\nLUN was too large asked %d max %d %p\n",lun,device->maxlun);
return (_kernel_oserror *)(ErrorNumber_SCSI_Died & 0xFF);
}
#ifdef DEBUGLIB
DEBUGf("CDB: %02x %02x %02x %02x %02x %02x ",
control_block[0],
......@@ -671,11 +677,11 @@ void glue_Tick(my_usb_device_t *device)
_kernel_irqs_off();
}
DEBUGf("Still in RX buffer: = %x, needed: = %x ", buffer_used,device->curr_transferlength);
if (buffer_used > device->curr_transferlength)
{
// flush the buffer.. we're done here
REMOVE_BLOCK(device->current_pipe->buffer, softc->scbulkoutbuf, buffer_used);
}
// if (buffer_used > device->curr_transferlength)
// {
// // flush the buffer.. we're done here
// REMOVE_BLOCK(device->current_pipe->buffer, softc->scbulkoutbuf, buffer_used);
// }
e = _swix(DeviceFS_CallDevice, _INR(0,2),
DeviceCall_MonitorRX,
device->devicefs_name,
......@@ -695,12 +701,6 @@ void glue_Tick(my_usb_device_t *device)
}
else
{
if(device->is_sensestatus && !device->curr_transferlength && buffer_used)
{
DEBUGf("Was sense status.. purging buffer of %x bytes\n ", buffer_used);
// flush the buffer.. we're done here
PURGE_SPACE(device->current_pipe->buffer);
}
device->status = USBD_NORMAL_COMPLETION;
if ((device->is_capacity) && ((softc->transfer_state == TSTATE_BBB_DATA) || (softc->transfer_state == TSTATE_CBI_DATA)) && (device->orig_scatterlist->length >= 8))
{
......@@ -736,6 +736,7 @@ void glue_Tick(my_usb_device_t *device)
{
DEBUGCHAR('K');
DEBUGf("Calling SCSIDriver from Tick, addr=%x err=%x r0=%x r4=%x r5=%x r12=%x\n", (int)device->callback, (int)device->callback_error, device->callback_status_byte, device->callback_not_transferred, (int)device->callback_pw, (int)device->callback_wp);
softc->transfer_priv = NULL; // make sure it cannot be repeated
asm_DoTransferCompleteCallback(device->callback_error,
device->callback_status_byte,
device->callback,
......@@ -859,6 +860,7 @@ static void Callback(struct umass_softc *softc, void *void_device, int not_trans
IGNORE(softc);
my_usb_device_t *device = (my_usb_device_t *)void_device;
DEBUGf("Callback, status %d\n",status);
if(!device)return; // already handled when it went wrong
switch (status)
{
case STATUS_CMD_OK:
......
......@@ -447,7 +447,7 @@ _kernel_oserror *module_SCSIRegister_cb(_kernel_swi_regs *r, void *pw)
{
if(!device->registered)
{
dprintf(("","Registering scsi device for %x \n",device));
dprintf(("","Registering scsi device for %p \n",device));
device->scsi_driver_handle =RegisterSCSIDevice(device);
device->registered = true;
}
......@@ -534,7 +534,7 @@ static uint32_t RegisterSCSIDevice(void *device)
global_PrivateWord,
device,
&scsi_driver_handle);
dprintf(("","Got scsi device handle %x \n",scsi_driver_handle));
dprintf(("","Got scsi device handle %x maxlun %d\n",scsi_driver_handle,((my_usb_device_t*)device)->maxlun));
return scsi_driver_handle;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment