From d4042e9c84864a5666dc8ec14b3c1a5597b6a73f Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Gollapudi Date: Fri, 10 Feb 2012 17:18:51 -0800 Subject: [SCSI] libfc: Fix panic in fc_exch_recv Adding and removing the host into the zone causes this panic. BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0 IP: [] fc_exch_recv+0xc57/0xe70 [libfc] Call Trace: [] bnx2fc_l2_rcv_thread+0x37b/0x430 [bnx2fc] [] ? bnx2fc_l2_rcv_thread+0x0/0x430 [bnx2fc] [] kthread+0x96/0xa0 [] child_rip+0xa/0x20 [] ? kthread+0x0/0xa0 [] ? child_rip+0x0/0x20 During fc_exch_reset, the active exchanges are aborted and the exch is deleted. As part of processing ABTS response, due to 'ep' being NULL, any access to ep in fc_exch_recv_bls() causes this panic. Fixed to access 'ep' only if non-NULL. Reviewed-by: Neerav Parikh Signed-off-by: Bhanu Prakash Gollapudi Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/libfc/fc_exch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/libfc/fc_exch.c') diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 4d70d96fa5d..630291f0182 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -1642,9 +1642,10 @@ static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp) case FC_RCTL_ACK_0: break; default: - FC_EXCH_DBG(ep, "BLS rctl %x - %s received", - fh->fh_r_ctl, - fc_exch_rctl_name(fh->fh_r_ctl)); + if (ep) + FC_EXCH_DBG(ep, "BLS rctl %x - %s received", + fh->fh_r_ctl, + fc_exch_rctl_name(fh->fh_r_ctl)); break; } fc_frame_free(fp); -- cgit v1.2.3-70-g09d2 From 011a9008b11604b12e8386fa6ac3433ab3175dc2 Mon Sep 17 00:00:00 2001 From: Steven Clark Date: Fri, 9 Mar 2012 14:50:30 -0800 Subject: [SCSI] libfc: fcoe_transport_create fails in single-CPU environment Starting fcoe fails at fcoe_transport_create when attempting to allocate a pool of 4K exchanges on a 64-bit single-CPU environment because the call to __alloc_percpu() is greater than the max of 32K. This patch reduces the number of exchanges to fit within the maximum allowed space. [ Whitespace problems fixed by Robert Love to satisfy chechpatch.pl ] Signed-off-by: Steven Clark Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/libfc/fc_exch.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/libfc/fc_exch.c') diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 630291f0182..aceffadb21c 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -2263,7 +2263,18 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lport, mp->class = class; /* adjust em exch xid range for offload */ mp->min_xid = min_xid; - mp->max_xid = max_xid; + + /* reduce range so per cpu pool fits into PCPU_MIN_UNIT_SIZE pool */ + pool_exch_range = (PCPU_MIN_UNIT_SIZE - sizeof(*pool)) / + sizeof(struct fc_exch *); + if ((max_xid - min_xid + 1) / (fc_cpu_mask + 1) > pool_exch_range) { + mp->max_xid = pool_exch_range * (fc_cpu_mask + 1) + + min_xid - 1; + } else { + mp->max_xid = max_xid; + pool_exch_range = (mp->max_xid - mp->min_xid + 1) / + (fc_cpu_mask + 1); + } mp->ep_pool = mempool_create_slab_pool(2, fc_em_cachep); if (!mp->ep_pool) @@ -2274,7 +2285,6 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lport, * divided across all cpus. The exch pointers array memory is * allocated for exch range per pool. */ - pool_exch_range = (mp->max_xid - mp->min_xid + 1) / (fc_cpu_mask + 1); mp->pool_max_index = pool_exch_range - 1; /* -- cgit v1.2.3-70-g09d2