Skip to contentSkip to conversation

drivers/hid/bpf/hid_bpf_dispatch.c:363:47: warning: cast from pointer to integer of different size

PATCH kernel test robot 1 participant 1 message Jun 28, 2024 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   642a16ca7994a50d7de85715996a8ce171a5bdfb
commit: 67eccf151d76a9939ad8a50c6db5cb486b01df24 [8744/9027] HID: add source argument to HID low level functions
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20240628/[email protected]/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240628/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/hid/bpf/hid_bpf_dispatch.c: In function 'hid_bpf_hw_request':

>> drivers/hid/bpf/hid_bpf_dispatch.c:363:47: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     363 |                                               (__u64)ctx);
         |                                               ^
   drivers/hid/bpf/hid_bpf_dispatch.c: In function 'hid_bpf_hw_output_report':
   drivers/hid/bpf/hid_bpf_dispatch.c:403:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     403 |                                                 (__u64)ctx);
         |                                                 ^
   drivers/hid/bpf/hid_bpf_dispatch.c: In function 'hid_bpf_input_report':
   drivers/hid/bpf/hid_bpf_dispatch.c:434:68: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     434 |         return hid_ops->hid_input_report(hdev, type, buf, size, 0, (__u64)ctx);
         |                                                                    ^

vim +363 drivers/hid/bpf/hid_bpf_dispatch.c

313
314 /**
315 * hid_bpf_hw_request - Communicate with a HID device
316 *
317 * @ctx: the HID-BPF context previously allocated in hid_bpf_allocate_context()
318 * @buf: a %PTR_TO_MEM buffer
319 * @buf__sz: the size of the data to transfer
320 * @rtype: the type of the report (%HID_INPUT_REPORT, %HID_FEATURE_REPORT, %HID_OUTPUT_REPORT)
321 * @reqtype: the type of the request (%HID_REQ_GET_REPORT, %HID_REQ_SET_REPORT, ...)
322 *
323 * @returns %0 on success, a negative error code otherwise.
324 */
325 __bpf_kfunc int
326 hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
327 enum hid_report_type rtype, enum hid_class_request reqtype)
328 {
329 struct hid_device *hdev;
330 size_t size = buf__sz;
331 u8 *dma_data;
332 int ret;
333
334 /* check arguments */
335 ret = __hid_bpf_hw_check_params(ctx, buf, &size, rtype);
336 if (ret)
337 return ret;
338
339 switch (reqtype) {
340 case HID_REQ_GET_REPORT:
341 case HID_REQ_GET_IDLE:
342 case HID_REQ_GET_PROTOCOL:
343 case HID_REQ_SET_REPORT:
344 case HID_REQ_SET_IDLE:
345 case HID_REQ_SET_PROTOCOL:
346 break;
347 default:
348 return -EINVAL;
349 }
350
351 hdev = (struct hid_device *)ctx->hid; /* discard const */
352
353 dma_data = kmemdup(buf, size, GFP_KERNEL);
354 if (!dma_data)
355 return -ENOMEM;
356
357 ret = hid_ops->hid_hw_raw_request(hdev,

   358						      dma_data[0],
   359						      dma_data,
   360						      size,
   361						      rtype,
   362						      reqtype,
 > 363						      (__u64)ctx);

364
365 if (ret > 0)
366 memcpy(buf, dma_data, ret);
367
368 kfree(dma_data);
369 return ret;
370 }
371

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki