aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/fcoe/fcoe_ctlr.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 9e83a790aa6b..692c6535fe75 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -164,28 +164,30 @@ static int fcoe_sysfs_fcf_add(struct fcoe_fcf *new)
164{ 164{
165 struct fcoe_ctlr *fip = new->fip; 165 struct fcoe_ctlr *fip = new->fip;
166 struct fcoe_ctlr_device *ctlr_dev = fcoe_ctlr_to_ctlr_dev(fip); 166 struct fcoe_ctlr_device *ctlr_dev = fcoe_ctlr_to_ctlr_dev(fip);
167 struct fcoe_fcf_device temp, *fcf_dev; 167 struct fcoe_fcf_device *temp, *fcf_dev;
168 int rc = 0; 168 int rc = -ENOMEM;
169 169
170 LIBFCOE_FIP_DBG(fip, "New FCF fab %16.16llx mac %pM\n", 170 LIBFCOE_FIP_DBG(fip, "New FCF fab %16.16llx mac %pM\n",
171 new->fabric_name, new->fcf_mac); 171 new->fabric_name, new->fcf_mac);
172 172
173 temp = kzalloc(sizeof(*temp), GFP_KERNEL);
174 if (!temp)
175 goto out;
176
173 mutex_lock(&ctlr_dev->lock); 177 mutex_lock(&ctlr_dev->lock);
174 178
175 temp.fabric_name = new->fabric_name; 179 temp->fabric_name = new->fabric_name;
176 temp.switch_name = new->switch_name; 180 temp->switch_name = new->switch_name;
177 temp.fc_map = new->fc_map; 181 temp->fc_map = new->fc_map;
178 temp.vfid = new->vfid; 182 temp->vfid = new->vfid;
179 memcpy(temp.mac, new->fcf_mac, ETH_ALEN); 183 memcpy(temp->mac, new->fcf_mac, ETH_ALEN);
180 temp.priority = new->pri; 184 temp->priority = new->pri;
181 temp.fka_period = new->fka_period; 185 temp->fka_period = new->fka_period;
182 temp.selected = 0; /* default to unselected */ 186 temp->selected = 0; /* default to unselected */
183 187
184 fcf_dev = fcoe_fcf_device_add(ctlr_dev, &temp); 188 fcf_dev = fcoe_fcf_device_add(ctlr_dev, temp);
185 if (unlikely(!fcf_dev)) { 189 if (unlikely(!fcf_dev))
186 rc = -ENOMEM; 190 goto unlock;
187 goto out;
188 }
189 191
190 /* 192 /*
191 * The fcoe_sysfs layer can return a CONNECTED fcf that 193 * The fcoe_sysfs layer can return a CONNECTED fcf that
@@ -204,9 +206,13 @@ static int fcoe_sysfs_fcf_add(struct fcoe_fcf *new)
204 206
205 list_add(&new->list, &fip->fcfs); 207 list_add(&new->list, &fip->fcfs);
206 fip->fcf_count++; 208 fip->fcf_count++;
209 rc = 0;
207 210
208out: 211unlock:
209 mutex_unlock(&ctlr_dev->lock); 212 mutex_unlock(&ctlr_dev->lock);
213
214out:
215 kfree(temp);
210 return rc; 216 return rc;
211} 217}
212 218