public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] Use of ref_get_unless_zero() ?
@ 2016-03-04 15:21 Andrew Lunn
  2016-03-04 15:37 ` Antonio Quartulli
  2016-03-04 15:50 ` Sven Eckelmann
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Lunn @ 2016-03-04 15:21 UTC (permalink / raw)
  To: B.A.T.M.A.N

Hi

I'm sometimes getting a crash after removing a hard interface when the
batadv_send_outstanding_bat_org_packet() is called in a work queue.
It calls

static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
                                        int packet_len, unsigned long send_time,
                                        bool direct_link,
                                        struct batadv_hard_iface *if_incoming,
                                        struct batadv_hard_iface *if_outgoing,
                                        int own_packet)
{
        struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
        struct batadv_forw_packet *forw_packet_aggr;
        unsigned char *skb_buff;
        unsigned int skb_size;

        if (!kref_get_unless_zero(&if_incoming->refcount))
                return;

        if (!kref_get_unless_zero(&if_outgoing->refcount))
                goto out_free_incoming;


Given that we have:

static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
{
        kref_put(&hard_iface->refcount, batadv_hardif_release);
}

does using kref_get_unless_zero() make sense? If it is zero, hasn't it
been freed by the kref_put that set it to zero?

Thanks
	Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-04 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-04 15:21 [B.A.T.M.A.N.] Use of ref_get_unless_zero() ? Andrew Lunn
2016-03-04 15:37 ` Antonio Quartulli
2016-03-04 15:50 ` Sven Eckelmann
2016-03-04 15:53   ` Sven Eckelmann
2016-03-04 16:00   ` Sven Eckelmann
2016-03-04 16:21   ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox