diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2007-07-27 19:13:33 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-07-28 10:58:28 -0400 |
commit | 92631fa4d0afa64b82144eab714fbf2f4049dabe (patch) | |
tree | 9d885b3d23c72241dff4b5bbaf2dca88b4c05ea3 /drivers/scsi/libsas | |
parent | 99d4d0a9f251a87e0710c6f1fb46ac0d4bce12cb (diff) |
[SCSI] libsas: Fix potential NULL dereference in sas_smp_get_phy_events()
In sas_smp_get_phy_events() we never test if the call to
alloc_smp_req(RPEL_REQ_SIZE) succeeds or fails. That means we run
the risk of dereferencing a NULL pointer if it does fail. Far
better to test if we got NULL back and in that case return -ENOMEM
just as we already do for the other memory allocation in that
function.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 8603ae65213d..8727436b222d 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -507,14 +507,21 @@ static int sas_dev_present_in_domain(struct asd_sas_port *port, | |||
507 | int sas_smp_get_phy_events(struct sas_phy *phy) | 507 | int sas_smp_get_phy_events(struct sas_phy *phy) |
508 | { | 508 | { |
509 | int res; | 509 | int res; |
510 | u8 *req; | ||
511 | u8 *resp; | ||
510 | struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent); | 512 | struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent); |
511 | struct domain_device *dev = sas_find_dev_by_rphy(rphy); | 513 | struct domain_device *dev = sas_find_dev_by_rphy(rphy); |
512 | u8 *req = alloc_smp_req(RPEL_REQ_SIZE); | ||
513 | u8 *resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL); | ||
514 | 514 | ||
515 | if (!resp) | 515 | req = alloc_smp_req(RPEL_REQ_SIZE); |
516 | if (!req) | ||
516 | return -ENOMEM; | 517 | return -ENOMEM; |
517 | 518 | ||
519 | resp = alloc_smp_resp(RPEL_RESP_SIZE); | ||
520 | if (!resp) { | ||
521 | kfree(req); | ||
522 | return -ENOMEM; | ||
523 | } | ||
524 | |||
518 | req[1] = SMP_REPORT_PHY_ERR_LOG; | 525 | req[1] = SMP_REPORT_PHY_ERR_LOG; |
519 | req[9] = phy->number; | 526 | req[9] = phy->number; |
520 | 527 | ||