[MPlayer-dev-eng] [FWD] Re: mga_vid.c ported to 2.6.0-test1 (from: algernon at debian.org)

Kronos kronos at kronoz.cjb.net
Sun Jul 20 18:13:55 CEST 2003


Il Sun, Jul 20, 2003 at 05:15:42PM +0200, Mark Szabo ha scritto: 
> Apparently, I overlooked the MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT
> stuff. Fixed patch below.

> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
>  	MOD_DEC_USE_COUNT;
> +#else
> +	module_put (THIS_MODULE);
> +#endif

> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
>  	MOD_INC_USE_COUNT;
> +#else
> +	try_module_get (THIS_MODULE);
> +#endif

This is  wrong.  You must  check the  return value of  try_module_get to
avoid race conditions. Also try_module_get/module_put  should be used by
the callee (for the same reason).

Please either leave MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT (which basically
are  try_module_get/module_put plus  a big  warning) or  add the  .owner
field to the struct file_operations:

static struct file_operations mga_vid_fops =
{
        ...
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
        .owner  = THIS_MODULE,
#endif
        ...
};

In this way the locking will be  controlled by the VFS layer and you can
remove try_module_get/module_put from the module.

HTH,
Luca
-- 
Reply-To: kronos at kronoz.cjb.net
Home: http://kronoz.cjb.net
La vispa candela bruciava l'erbetta
creando un'essenza alquanto sospetta;
sembrava l'odore di una sacrestia
ma presto mi accorsi che era maria.



More information about the MPlayer-dev-eng mailing list