diff mbox series

misc: uacce - add the null check for the input pointer and its pointer members

Message ID 20240329062655.3055646-1-huangchenghai2@huawei.com
State New
Headers show
Series misc: uacce - add the null check for the input pointer and its pointer members | expand

Commit Message

Chenghai Huang March 29, 2024, 6:26 a.m. UTC
The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
pointer verification is added on the pointer type input parameter and its
pointer members.

Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
 drivers/misc/uacce/uacce.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Greg KH March 29, 2024, 6:34 a.m. UTC | #1
On Fri, Mar 29, 2024 at 02:26:55PM +0800, Chenghai Huang wrote:
> The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
> pointer verification is added on the pointer type input parameter and its
> pointer members.

I do not understand, why does the export type matter?  Just fix any
callers to use this properly and send proper parameters.  What in-tree
caller needs this?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
index bdc2e6fda782..964f1a6a16e0 100644
--- a/drivers/misc/uacce/uacce.c
+++ b/drivers/misc/uacce/uacce.c
@@ -514,6 +514,9 @@  struct uacce_device *uacce_alloc(struct device *parent,
 	struct uacce_device *uacce;
 	int ret;
 
+	if (!parent || !interface || !interface->ops)
+		return ERR_PTR(-EINVAL);
+
 	uacce = kzalloc(sizeof(struct uacce_device), GFP_KERNEL);
 	if (!uacce)
 		return ERR_PTR(-ENOMEM);