diff options
author | Christophe Jaillet <christophe.jaillet@wanadoo.fr> | 2016-10-30 15:35:57 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-11-18 06:41:08 -0500 |
commit | 5cd4f5cec2374d2c09299211d2b357cc160e49a0 (patch) | |
tree | ce3b26e8ff9f15d493a6e94c06e27ec55d1ce429 /drivers/misc | |
parent | 7458e8b2ce62e65051fec0bcb14cac35d4f1118d (diff) |
cxl: Fix memory allocation failure test
'cxl_context_alloc()' does not return an error pointer. It is just a
shortcut for a call to 'kzalloc' with 'sizeof(struct cxl_context)' as the
size parameter.
So its return value should be compared with NULL.
While fixing it, simplify a bit the code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/cxl/api.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 2e5233b60971..2b88ad8a2a89 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c | |||
@@ -30,10 +30,8 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) | |||
30 | return ERR_CAST(afu); | 30 | return ERR_CAST(afu); |
31 | 31 | ||
32 | ctx = cxl_context_alloc(); | 32 | ctx = cxl_context_alloc(); |
33 | if (IS_ERR(ctx)) { | 33 | if (!ctx) |
34 | rc = PTR_ERR(ctx); | 34 | return ERR_PTR(-ENOMEM); |
35 | goto err_dev; | ||
36 | } | ||
37 | 35 | ||
38 | ctx->kernelapi = true; | 36 | ctx->kernelapi = true; |
39 | 37 | ||
@@ -61,7 +59,6 @@ err_mapping: | |||
61 | kfree(mapping); | 59 | kfree(mapping); |
62 | err_ctx: | 60 | err_ctx: |
63 | kfree(ctx); | 61 | kfree(ctx); |
64 | err_dev: | ||
65 | return ERR_PTR(rc); | 62 | return ERR_PTR(rc); |
66 | } | 63 | } |
67 | EXPORT_SYMBOL_GPL(cxl_dev_context_init); | 64 | EXPORT_SYMBOL_GPL(cxl_dev_context_init); |