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>
This commit is contained in:
Родитель
7458e8b2ce
Коммит
5cd4f5cec2
|
@ -30,10 +30,8 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
|
||||||
return ERR_CAST(afu);
|
return ERR_CAST(afu);
|
||||||
|
|
||||||
ctx = cxl_context_alloc();
|
ctx = cxl_context_alloc();
|
||||||
if (IS_ERR(ctx)) {
|
if (!ctx)
|
||||||
rc = PTR_ERR(ctx);
|
return ERR_PTR(-ENOMEM);
|
||||||
goto err_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->kernelapi = true;
|
ctx->kernelapi = true;
|
||||||
|
|
||||||
|
@ -61,7 +59,6 @@ err_mapping:
|
||||||
kfree(mapping);
|
kfree(mapping);
|
||||||
err_ctx:
|
err_ctx:
|
||||||
kfree(ctx);
|
kfree(ctx);
|
||||||
err_dev:
|
|
||||||
return ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(cxl_dev_context_init);
|
EXPORT_SYMBOL_GPL(cxl_dev_context_init);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче