[B.A.T.M.A.N.] [PATCH 08/10] batman-adv: Adding batman_if specific sysfs wrapper macros for UINT

Marek Lindner lindner_marek at yahoo.de
Tue Dec 28 16:14:29 CET 2010


On Tuesday 14 December 2010 10:58:14 Linus Lüssing wrote:
> +#define BAT_ATTR_IF_STORE_UINT(_name, _min, _max, _post_func)          \
> +ssize_t store_##_name(struct kobject *kobj, struct attribute *attr,    \
> +                            char *buff, size_t count)                  \
> +{                                                                      \
> +       struct net_device *net_dev = kobj_to_netdev(kobj);              \
> +       struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); \
> +       return __store_uint_attr(buff, count, _min, _max, _post_func,   \
> +                                attr, &batman_if->_name, net_dev);     \
> +}
> +
> +#define BAT_ATTR_IF_SHOW_UINT(_name)                                   \
> +ssize_t show_##_name(struct kobject *kobj, struct attribute *attr,     \
> +                           char *buff)                                 \
> +{                                                                      \
> +       struct net_device *net_dev = kobj_to_netdev(kobj);              \
> +       struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); \
> +       return sprintf(buff, "%i\n", atomic_read(&batman_if->_name));   \
> +}     

get_batman_if_by_netdev() increases the batman_if refcount which is never 
decreased. Check the other get_batman_if_by_netdev() calls in the same file to 
get an idea how to handle this,

Cheers,
Marek



More information about the B.A.T.M.A.N mailing list