All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [SCSI] pm8001: Add error handler in pm8001_init_sas_add() if kzalloc fails.
  2012-03-21  8:49 ` James Bottomley
@ 2012-03-21  8:50 ` santosh nayak
  2012-03-21 10:50   ` walter harms
  2012-03-21 11:06   ` Dan Carpenter
  2 siblings, 0 replies; 12+ messages in thread
From: santosh nayak @ 2012-03-21  8:38 UTC (permalink / raw)
  To: jack_wang
  Cc: mark_salyzyn, lindar_liu, JBottomley, linux-scsi, kernel-janitors,
	Santosh Nayak

From: Santosh Nayak <santoshprasadnayak@gmail.com>

We need to add error handler if kzalloc fails to allocate and initialize.
Otherwise it may lead to Null derefernce error in 
'pm8001_chip_get_nvmd_req()'.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
 drivers/scsi/pm8001/pm8001_init.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 36efaa7..fdce28e 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -519,6 +519,10 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
 	payload.minor_function = 0;
 	payload.length = 128;
 	payload.func_specific = kzalloc(128, GFP_KERNEL);
+	if (unlikely(!payload.func_specific)) {
+		printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
+		return;
+	}
 	PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
 	wait_for_completion(&completion);
 	for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-03-22  1:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21  8:38 [PATCH] [SCSI] pm8001: Add error handler in pm8001_init_sas_add() if kzalloc fails santosh nayak
2012-03-21  8:50 ` santosh nayak
2012-03-21  8:49 ` James Bottomley
2012-03-21  8:58   ` Dan Carpenter
2012-03-21  8:58     ` Dan Carpenter
2012-03-21 10:11     ` James Bottomley
2012-03-21 10:50   ` walter harms
2012-03-21 11:06   ` Dan Carpenter
2012-03-21 17:11 ` Mark Salyzyn
2012-03-21 17:11   ` Mark Salyzyn
2012-03-22  1:49 ` Jack Wang
2012-03-22  1:49   ` Jack Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.