lkml.org 
[lkml]   [2001]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH] DAC960.c - Null ptr fixes
Date
We revised the DAC960.c patch to include the helpful advice given, as well 
as improving style issues. Is there a good reason why the code has been
copied and pasted so much? This copying and pasting business multiplies the
same error very quickly.

Praveen Srinivasan and Frederick Akalin


--- ./drivers/block/DAC960.c.orig Thu May 24 23:27:46 2001
+++ ./drivers/block/DAC960.c Thu May 24 23:26:16 2001
@@ -506,8 +506,12 @@
void *DataPointer)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
+ DAC960_V1_CommandMailbox_T *CommandMailbox;
DAC960_V1_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V1.CommandMailbox;
DAC960_V1_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->Type3.CommandOpcode = CommandOpcode;
@@ -531,9 +535,14 @@
unsigned char TargetID,
void *DataPointer)
{
+
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
+ DAC960_V1_CommandMailbox_T *CommandMailbox;
DAC960_V1_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V1.CommandMailbox;
DAC960_V1_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->Type3D.CommandOpcode = CommandOpcode;
@@ -559,8 +568,12 @@
unsigned int DataByteCount)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
+ DAC960_V2_CommandMailbox_T *CommandMailbox;
DAC960_V2_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V2.CommandMailbox;
DAC960_V2_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
@@ -597,9 +610,12 @@
unsigned int DataByteCount)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
+ DAC960_V2_CommandMailbox_T *CommandMailbox;
DAC960_V2_CommandStatus_T CommandStatus;
- DAC960_V2_ClearCommand(Command);
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V2.CommandMailbox;
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
CommandMailbox->ControllerInfo.CommandControlBits
@@ -639,8 +655,12 @@
unsigned int DataByteCount)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
+ DAC960_V2_CommandMailbox_T *CommandMailbox;
DAC960_V2_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V2.CommandMailbox;
DAC960_V2_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->LogicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
@@ -683,8 +703,12 @@
unsigned int DataByteCount)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
+ DAC960_V2_CommandMailbox_T *CommandMailbox;
DAC960_V2_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V2.CommandMailbox;
DAC960_V2_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
@@ -724,8 +748,12 @@
OperationDevice)
{
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
- DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
+ DAC960_V2_CommandMailbox_T *CommandMailbox;
DAC960_V2_CommandStatus_T CommandStatus;
+ if(Command == NULL) {
+ return 0;
+ }
+ CommandMailbox = &Command->V2.CommandMailbox;
DAC960_V2_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->DeviceOperation.CommandOpcode = DAC960_V2_IOCTL;
@@ -1435,8 +1463,12 @@
InquiryUnitSerialNumber;
memset(InquiryUnitSerialNumber, 0,
sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
- InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
+ InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
Command = DAC960_AllocateCommand(Controller);
+ if(Command == NULL) {
+ return DAC960_Failure(Controller, "COMMAND ALLOCATION");
+ }
+
CommandMailbox = &Command->V2.CommandMailbox;
DAC960_V2_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
@@ -6594,6 +6626,8 @@
create_proc_read_entry("user_command", S_IWUSR | S_IRUSR,
ControllerProcEntry, DAC960_ProcReadUserCommand,
Controller);
+ if(UserCommandProcEntry == NULL) continue;
+
UserCommandProcEntry->write_proc = DAC960_ProcWriteUserCommand;
Controller->ControllerProcEntry = ControllerProcEntry;
}








-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:53    [W:0.074 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site