[PATCH] media: em28xx: Fix race condition between open and init function

kernel test robot lkp at intel.com
Thu Apr 8 15:38:41 UTC 2021


Hi Igor,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.12-rc6 next-20210408]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Igor-Matheus-Andrade-Torrente/media-em28xx-Fix-race-condition-between-open-and-init-function/20210408-201217
base:   git://linuxtv.org/media_tree.git master
config: x86_64-randconfig-a014-20210408 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 56ea2e2fdd691136d5e6631fa0e447173694b82c)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/e13d07271a1ee4cbd8ac421bf575a36f9d0e1008
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Igor-Matheus-Andrade-Torrente/media-em28xx-Fix-race-condition-between-open-and-init-function/20210408-201217
        git checkout e13d07271a1ee4cbd8ac421bf575a36f9d0e1008
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>

All warnings (new ones prefixed by >>):

>> drivers/media/usb/em28xx/em28xx-video.c:2347:6: warning: no previous prototype for function 'em28xx_vdev_release' [-Wmissing-prototypes]
   void em28xx_vdev_release(struct video_device *vdev)
        ^
   drivers/media/usb/em28xx/em28xx-video.c:2347:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void em28xx_vdev_release(struct video_device *vdev)
   ^
   static 
>> drivers/media/usb/em28xx/em28xx-video.c:2545:6: warning: no previous prototype for function 'em28xx_v4l2_dev_release' [-Wmissing-prototypes]
   void em28xx_v4l2_dev_release(struct v4l2_device *v4l2_dev)
        ^
   drivers/media/usb/em28xx/em28xx-video.c:2545:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void em28xx_v4l2_dev_release(struct v4l2_device *v4l2_dev)
   ^
   static 
   2 warnings generated.


vim +/em28xx_vdev_release +2347 drivers/media/usb/em28xx/em28xx-video.c

  2346	
> 2347	void em28xx_vdev_release(struct video_device *vdev)
  2348	{
  2349	#ifdef CONFIG_MEDIA_CONTROLLER
  2350		int i;
  2351	
  2352		for (i = 0; i < vdev->entity.num_pads; i++)
  2353			kfree(&vdev->entity.pads[i]);
  2354	#endif
  2355		kfree(vdev);
  2356	}
  2357	
  2358	static const struct v4l2_file_operations em28xx_v4l_fops = {
  2359		.owner         = THIS_MODULE,
  2360		.open          = em28xx_v4l2_open,
  2361		.release       = em28xx_v4l2_close,
  2362		.read          = vb2_fop_read,
  2363		.poll          = vb2_fop_poll,
  2364		.mmap          = vb2_fop_mmap,
  2365		.unlocked_ioctl = video_ioctl2,
  2366	};
  2367	
  2368	static const struct v4l2_ioctl_ops video_ioctl_ops = {
  2369		.vidioc_querycap            = vidioc_querycap,
  2370		.vidioc_enum_fmt_vid_cap    = vidioc_enum_fmt_vid_cap,
  2371		.vidioc_g_fmt_vid_cap       = vidioc_g_fmt_vid_cap,
  2372		.vidioc_try_fmt_vid_cap     = vidioc_try_fmt_vid_cap,
  2373		.vidioc_s_fmt_vid_cap       = vidioc_s_fmt_vid_cap,
  2374		.vidioc_g_fmt_vbi_cap       = vidioc_g_fmt_vbi_cap,
  2375		.vidioc_try_fmt_vbi_cap     = vidioc_g_fmt_vbi_cap,
  2376		.vidioc_s_fmt_vbi_cap       = vidioc_g_fmt_vbi_cap,
  2377		.vidioc_enum_framesizes     = vidioc_enum_framesizes,
  2378		.vidioc_enumaudio           = vidioc_enumaudio,
  2379		.vidioc_g_audio             = vidioc_g_audio,
  2380		.vidioc_s_audio             = vidioc_s_audio,
  2381	
  2382		.vidioc_reqbufs             = vb2_ioctl_reqbufs,
  2383		.vidioc_create_bufs         = vb2_ioctl_create_bufs,
  2384		.vidioc_prepare_buf         = vb2_ioctl_prepare_buf,
  2385		.vidioc_querybuf            = vb2_ioctl_querybuf,
  2386		.vidioc_qbuf                = vb2_ioctl_qbuf,
  2387		.vidioc_dqbuf               = vb2_ioctl_dqbuf,
  2388	
  2389		.vidioc_g_std               = vidioc_g_std,
  2390		.vidioc_querystd            = vidioc_querystd,
  2391		.vidioc_s_std               = vidioc_s_std,
  2392		.vidioc_g_parm		    = vidioc_g_parm,
  2393		.vidioc_s_parm		    = vidioc_s_parm,
  2394		.vidioc_enum_input          = vidioc_enum_input,
  2395		.vidioc_g_input             = vidioc_g_input,
  2396		.vidioc_s_input             = vidioc_s_input,
  2397		.vidioc_streamon            = vb2_ioctl_streamon,
  2398		.vidioc_streamoff           = vb2_ioctl_streamoff,
  2399		.vidioc_g_tuner             = vidioc_g_tuner,
  2400		.vidioc_s_tuner             = vidioc_s_tuner,
  2401		.vidioc_g_frequency         = vidioc_g_frequency,
  2402		.vidioc_s_frequency         = vidioc_s_frequency,
  2403		.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
  2404		.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
  2405	#ifdef CONFIG_VIDEO_ADV_DEBUG
  2406		.vidioc_g_chip_info         = vidioc_g_chip_info,
  2407		.vidioc_g_register          = vidioc_g_register,
  2408		.vidioc_s_register          = vidioc_s_register,
  2409	#endif
  2410	};
  2411	
  2412	static const struct video_device em28xx_video_template = {
  2413		.fops		= &em28xx_v4l_fops,
  2414		.ioctl_ops	= &video_ioctl_ops,
  2415		.release	= em28xx_vdev_release,
  2416		.tvnorms	= V4L2_STD_ALL,
  2417	};
  2418	
  2419	static const struct v4l2_file_operations radio_fops = {
  2420		.owner         = THIS_MODULE,
  2421		.open          = em28xx_v4l2_open,
  2422		.release       = em28xx_v4l2_close,
  2423		.unlocked_ioctl = video_ioctl2,
  2424	};
  2425	
  2426	static const struct v4l2_ioctl_ops radio_ioctl_ops = {
  2427		.vidioc_querycap      = vidioc_querycap,
  2428		.vidioc_g_tuner       = radio_g_tuner,
  2429		.vidioc_s_tuner       = radio_s_tuner,
  2430		.vidioc_g_frequency   = vidioc_g_frequency,
  2431		.vidioc_s_frequency   = vidioc_s_frequency,
  2432		.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
  2433		.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
  2434	#ifdef CONFIG_VIDEO_ADV_DEBUG
  2435		.vidioc_g_chip_info   = vidioc_g_chip_info,
  2436		.vidioc_g_register    = vidioc_g_register,
  2437		.vidioc_s_register    = vidioc_s_register,
  2438	#endif
  2439	};
  2440	
  2441	static struct video_device em28xx_radio_template = {
  2442		.fops		= &radio_fops,
  2443		.ioctl_ops	= &radio_ioctl_ops,
  2444		.release	= video_device_release_empty,
  2445	};
  2446	
  2447	/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
  2448	static unsigned short saa711x_addrs[] = {
  2449		0x4a >> 1, 0x48 >> 1,   /* SAA7111, SAA7111A and SAA7113 */
  2450		0x42 >> 1, 0x40 >> 1,   /* SAA7114, SAA7115 and SAA7118 */
  2451		I2C_CLIENT_END };
  2452	
  2453	static unsigned short tvp5150_addrs[] = {
  2454		0xb8 >> 1,
  2455		0xba >> 1,
  2456		I2C_CLIENT_END
  2457	};
  2458	
  2459	static unsigned short msp3400_addrs[] = {
  2460		0x80 >> 1,
  2461		0x88 >> 1,
  2462		I2C_CLIENT_END
  2463	};
  2464	
  2465	/******************************** usb interface ******************************/
  2466	
  2467	static void em28xx_vdev_init(struct em28xx *dev,
  2468				     struct video_device *vfd,
  2469				     const struct video_device *template,
  2470				     const char *type_name)
  2471	{
  2472		*vfd		= *template;
  2473		vfd->v4l2_dev	= dev->v4l2->v4l2_dev;
  2474		vfd->lock	= &dev->lock;
  2475		if (dev->is_webcam)
  2476			vfd->tvnorms = 0;
  2477	
  2478		snprintf(vfd->name, sizeof(vfd->name), "%s %s",
  2479			 dev_name(&dev->intf->dev), type_name);
  2480	
  2481		video_set_drvdata(vfd, dev);
  2482	}
  2483	
  2484	static void em28xx_tuner_setup(struct em28xx *dev, unsigned short tuner_addr)
  2485	{
  2486		struct em28xx_v4l2      *v4l2 = dev->v4l2;
  2487		struct v4l2_device      *v4l2_dev = v4l2->v4l2_dev;
  2488		struct tuner_setup      tun_setup;
  2489		struct v4l2_frequency   f;
  2490	
  2491		memset(&tun_setup, 0, sizeof(tun_setup));
  2492	
  2493		tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
  2494		tun_setup.tuner_callback = em28xx_tuner_callback;
  2495	
  2496		if (dev->board.radio.type) {
  2497			tun_setup.type = dev->board.radio.type;
  2498			tun_setup.addr = dev->board.radio_addr;
  2499	
  2500			v4l2_device_call_all(v4l2_dev,
  2501					     0, tuner, s_type_addr, &tun_setup);
  2502		}
  2503	
  2504		if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type) {
  2505			tun_setup.type   = dev->tuner_type;
  2506			tun_setup.addr   = tuner_addr;
  2507	
  2508			v4l2_device_call_all(v4l2_dev,
  2509					     0, tuner, s_type_addr, &tun_setup);
  2510		}
  2511	
  2512		if (dev->board.tda9887_conf) {
  2513			struct v4l2_priv_tun_config tda9887_cfg;
  2514	
  2515			tda9887_cfg.tuner = TUNER_TDA9887;
  2516			tda9887_cfg.priv = &dev->board.tda9887_conf;
  2517	
  2518			v4l2_device_call_all(v4l2_dev,
  2519					     0, tuner, s_config, &tda9887_cfg);
  2520		}
  2521	
  2522		if (dev->tuner_type == TUNER_XC2028) {
  2523			struct v4l2_priv_tun_config  xc2028_cfg;
  2524			struct xc2028_ctrl           ctl;
  2525	
  2526			memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
  2527			memset(&ctl, 0, sizeof(ctl));
  2528	
  2529			em28xx_setup_xc3028(dev, &ctl);
  2530	
  2531			xc2028_cfg.tuner = TUNER_XC2028;
  2532			xc2028_cfg.priv  = &ctl;
  2533	
  2534			v4l2_device_call_all(v4l2_dev, 0, tuner, s_config, &xc2028_cfg);
  2535		}
  2536	
  2537		/* configure tuner */
  2538		f.tuner = 0;
  2539		f.type = V4L2_TUNER_ANALOG_TV;
  2540		f.frequency = 9076;     /* just a magic number */
  2541		v4l2->frequency = f.frequency;
  2542		v4l2_device_call_all(v4l2_dev, 0, tuner, s_frequency, &f);
  2543	}
  2544	
> 2545	void em28xx_v4l2_dev_release(struct v4l2_device *v4l2_dev)
  2546	{
  2547		kfree(v4l2_dev);
  2548	}
  2549	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 46852 bytes
Desc: not available
URL: <http://lists.linuxfoundation.org/pipermail/linux-kernel-mentees/attachments/20210408/abb5739c/attachment-0001.gz>


More information about the Linux-kernel-mentees mailing list