[gabbayo:habanalabs-next 24/32] drivers/misc/habanalabs/habanalabs_ioctl.c:143:10-17: WARNING opportunity for memdup_user

kbuild test robot lkp at intel.com
Sun Apr 7 19:19:13 UTC 2019


tree:   git://people.freedesktop.org/~gabbayo/linux habanalabs-next
head:   19b649b1933c3ed065426d612345115d15d90f23
commit: e4d7235a3c44a17cb0a70e8dde768b6345ba5dd4 [24/32] habanalabs: add new IOCTL for debug, tracing and profiling


coccinelle warnings: (new ones prefixed by >>)

>> drivers/misc/habanalabs/habanalabs_ioctl.c:143:10-17: WARNING opportunity for memdup_user

vim +143 drivers/misc/habanalabs/habanalabs_ioctl.c

   127	
   128	static int debug_coresight(struct hl_device *hdev, struct hl_debug_args *args)
   129	{
   130		struct hl_debug_params *params;
   131		void *input = NULL, *output = NULL;
   132		int rc;
   133	
   134		params = kzalloc(sizeof(*params), GFP_KERNEL);
   135		if (!params)
   136			return -ENOMEM;
   137	
   138		params->reg_idx = args->reg_idx;
   139		params->enable = args->enable;
   140		params->op = args->op;
   141	
   142		if (args->input_ptr && args->input_size) {
 > 143			input = kzalloc(args->input_size, GFP_KERNEL);
   144			if (!input) {
   145				rc = -ENOMEM;
   146				goto out;
   147			}
   148	
   149			if (copy_from_user(input,
   150					(void __user *) (uintptr_t) args->input_ptr,
   151					args->input_size)) {
   152				dev_err(hdev->dev,
   153					"copy from user failed in debug ioctl\n");
   154				rc = -EFAULT;
   155				goto out;
   156			}
   157	
   158			params->input = input;
   159		}
   160	
   161		if (args->output_ptr && args->output_size) {
   162			output = kzalloc(args->output_size, GFP_KERNEL);
   163			if (!output) {
   164				rc = -ENOMEM;
   165				goto out;
   166			}
   167	
   168			params->output = output;
   169			params->output_size = args->output_size;
   170		}
   171	
   172		rc = hdev->asic_funcs->debug_coresight(hdev, params);
   173		if (rc) {
   174			dev_err(hdev->dev,
   175				"debug coresight operation failed %d\n", rc);
   176			goto out;
   177		}
   178	
   179		if (output) {
   180			if (copy_to_user((void __user *) (uintptr_t) args->output_ptr,
   181						output,
   182						args->output_size)) {
   183				dev_err(hdev->dev,
   184					"copy to user failed in debug ioctl\n");
   185				rc = -EFAULT;
   186				goto out;
   187			}
   188		}
   189	
   190	out:
   191		kfree(params);
   192		kfree(output);
   193		kfree(input);
   194	
   195		return rc;
   196	}
   197	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


More information about the dri-devel mailing list