scsi: megaraid: check kzalloc
Subsystems (2)
PATCH 1/1 scsi: megaraid: check kzalloc
we should check kzalloc, avoid to hit oops
--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/megaraid.c +4 -0
@@ -4162,6 +4162,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); scmd->device = sdev; +if (!scmd->device) { +scsi_free_command (GFP_KERNEL , scmd); +return -ENOMEM ; + }memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb)); scmd->cmnd = adapter->int_cdb;
Signature · 1 line
1.7.1
Quoted 13 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)drivers/scsi/megaraid.c +0
-0
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4164
Quoted 3 lines
drivers/scsi/megaraid.c +0
-0@@ -4162,6 +4162,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); scmd->device = sdev;
^^^^^^
I guess assigning after the NULL check of 'sdev' is more appropriate.
Quoted 14 lines
drivers/scsi/megaraid.c +4
-1+if (!scmd->device) { +scsi_free_command (GFP_KERNEL , scmd); +return -ENOMEM ; + }memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb)); scmd->cmnd = adapter->int_cdb; --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
~Santosh
Quoted 15 lines · Santosh Y
Quoted 14 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)drivers/scsi/megaraid.c +0
-0@@ -4162,6 +4162,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
Quoted 4 lines
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4164
Quoted 2 lines
drivers/scsi/megaraid.c +0
-0sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); scmd->device = sdev;^^^^^^I guess assigning after the NULL check of 'sdev' is more appropriate.
Ah, there is a little different. ok, I will update.
Thanks,
Libo
Quoted 18 lines
Quoted 15 lines
drivers/scsi/megaraid.c +4
-1+if (!scmd->device) { +scsi_free_command (GFP_KERNEL , scmd); +return -ENOMEM ; + }memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb)); scmd->cmnd = adapter->int_cdb; --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 1/1 scsi: megaraid: check kzalloc
In reply to Libo Chenwe should check kzalloc, avoid to hit oops
--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
instead of checking scmd->device, sdev is more appropriate.
drivers/scsi/megaraid.c +4 -0
@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t)); sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd); +return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));
Signature · 1 line
1.7.1
Quoted 14 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)instead of checking
scmd->device, sdev is more appropriate.drivers/scsi/megaraid.c +0
-0
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4165
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t)); sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd);
I think, that a mutex_unlock(&adapter->int_mtx); is also needed Maybe just setting a rval = -ENOMEM and a jump to to some point below?
tomash
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0+return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));
Quoted 14 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)instead of checking
scmd->device, sdev is more appropriate.drivers/scsi/megaraid.c +0
-0
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4165
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t)); sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd);
I think, that a mutex_unlock(&adapter->int_mtx); is also needed Maybe just setting a rval = -ENOMEM and a jump to to some point below?
tomash
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0+return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));
Quoted 17 lines · Tomas Henzl
Quoted 16 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)instead of checking
scmd->device, sdev is more appropriate.drivers/scsi/megaraid.c +0
-0@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t));
Quoted 8 lines
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4165
Quoted 3 lines
drivers/scsi/megaraid.c +2
-0sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd);I think, that a
mutex_unlock(&adapter->int_mtx); is also needed Maybe just setting a rval =-ENOMEMand a jump to to some point below?tomash
thanks for catching this.
when kzalloc broken, fist unlock and then return. I will update later.
Libo
Quoted 10 lines
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4170
Quoted 6 lines
drivers/scsi/megaraid.c +2
-0+return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));.
Quoted 25 lines · Libo Chen
Quoted 24 lines · Tomas Henzl
Quoted 14 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)instead of checking
scmd->device, sdev is more appropriate.drivers/scsi/megaraid.c +0
-0drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4165
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t)); sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd);I think, that a
mutex_unlock(&adapter->int_mtx); is also needed Maybe just setting a rval =-ENOMEMand a jump to to some point below?
Quoted 6 lines
Quoted 1 line
tomash
thanks for catching this.
when kzalloc broken, fist unlock and then return. I will update later.
I think we can put kzalloc outside of mutex_lock(&adapter->int_mtx) ? phase:
mutex_lock kzalloc
kzalloc -> mutex_lock
Quoted 14 lines
Libo
Quoted 10 lines
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4170
Quoted 6 lines
drivers/scsi/megaraid.c +2
-0+return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));.
Quoted 25 lines · Libo Chen
Quoted 24 lines · Libo Chen
Quoted 23 lines · Tomas Henzl
Quoted 14 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Signed-off-by Libo Chen <[email protected]>--- drivers/scsi/megaraid.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)instead of checking
scmd->device, sdev is more appropriate.drivers/scsi/megaraid.c +0
-0drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4165
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0@@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)memset (scb,0 ,sizeof (scb_t)); sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (sdev) { +scsi_free_command (GFP_KERNEL , scmd);I think, that a
mutex_unlock(&adapter->int_mtx); is also needed Maybe just setting a rval =-ENOMEMand a jump to to some point below?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
tomash
thanks for catching this.
when kzalloc broken, fist unlock and then return. I will update later.
I think we can put kzalloc outside of
mutex_lock(&adapter->int_mtx)? phase:
Yes, that is also possible, depends on what you prefer.
Quoted 20 lines
mutex_lock kzalloc kzalloc -> mutex_lockQuoted 10 lines
Libo
Quoted 8 lines
drivers/scsi/megaraid.c mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) · line 4170
Quoted 5 lines
drivers/scsi/megaraid.c +2
-0+return -ENOMEM ; + } scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
we should check kzalloc, avoid to hit oops
Change from v1:
- put kzalloc outside of mutex
--- drivers/scsi/megaraid.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/scsi/megaraid.c +6 -1
@@ -4150,6 +4150,12 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)if (!scmd)return -ENOMEM ; + sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); +if (!sdev) { +scsi_free_command (GFP_KERNEL , scmd); +return -ENOMEM ; + } +/* * The internal commands share one command id and hence are * serialized. This is so because we want to reserve maximum number of
@@ -4160,7 +4166,6 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) scb = &adapter->int_scb;memset (scb,0 ,sizeof (scb_t)); - sdev =kzalloc (sizeof (struct scsi_device ),GFP_KERNEL ); scmd->device = sdev;memset (adapter->int_cdb,0 ,sizeof (adapter->int_cdb));
Signature · 1 line
1.7.1
Tomas Henzl
Acked-byQuoted 6 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Change from v1:
- put kzalloc outside of mutexSigned-off-by Libo Chen <[email protected]>
Your patch looks fine to me:
Cheers,
Tomas
Quoted 11 lines · Tomas Henzl
Quoted 6 lines · Libo Chen
we should check kzalloc, avoid to hit oops
Change from v1:
- put kzalloc outside of mutexSigned-off-by Libo Chen <[email protected]>Your patch looks fine to me:
Acked-by Tomas Henzl <[email protected]>
your ack is very helpfull for me.
Thanks,
Libo
Quoted 6 lines
Cheers,
Tomas.