Not every failure is due to out-of-memory; the ACLs might not be set, too. So return a detailed error code in ft_sess_create() instead of just a NULL pointer.
Unified · Split
| @@ -223,7 +223,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, · 222 unmodified lines | ||
| 223 | 223 | |
| 224 | 224 | sess = kzalloc(sizeof(*sess), GFP_KERNEL); |
| 225 | 225 | if (!sess) |
| 226 | − return NULL; | |
| 226 | + return ERR_PTR(-ENOMEM); | |
| 227 | 227 | |
| 228 | 228 | kref_init(&sess->kref); /* ref for table entry */ |
| 229 | 229 | sess->tport = tport; |
| @@ -234,8 +234,9 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, · 4 unmodified lines | ||
| 234 | 234 | TARGET_PROT_NORMAL, &initiatorname[0], |
| 235 | 235 | sess, ft_sess_alloc_cb); |
| 236 | 236 | if (IS_ERR(sess->se_sess)) { |
| 237 | + int rc = PTR_ERR(sess->se_sess); | |
| 237 | 238 | kfree(sess); |
| 238 | − return NULL; | |
| 239 | + sess = ERR_PTR(rc); | |
| 239 | 240 | } |
| 240 | 241 | return sess; |
| 241 | 242 | } |