Welcome! Log In Create A New Profile


Null pointer when accessing private data of device driver from other device driver

Posted by Rafael Nagel 
I am developing a module which works as a layer between mac80211 module and ath9k device driver (I have done that by exporting ath9k_ops, then accessing it in my module and changing the callback functions in order to point to functions in my module).

For now, my module just intercepts mac80211 callback operations (by struct ieee80211_ops) and forward them to the device driver.

Part of struct ieee80211_ops is:

struct ieee80211_ops {
    void (*tx)(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb);
    /* other callback functions ... */

This way, when module 80211 calls callback function (*tx) I can access members of the structs ieee80211_hw, ieee80211_tx_control, sk_buff, except the pointer pointing to private data of the device:

struct ath_softc *sc = hw->priv;

What I am not following is that the original callback function of the ath9k device driver (which I call at the end of my callback function) does exactly the same thing:

static void ath9k_tx(struct ieee80211_hw *hw,
         struct ieee80211_tx_control *control,
         struct sk_buff *skb)
    struct ath_softc *sc = hw->priv;
    /* other code accessing members of struct ath_softc normally */

So, why can't my module access the private data and ath9k module can?

I think I provided enough information regarding the problem because the issue is probably related to the way private data is protected from other modules accessing it, and it's my fault in not understanding how memory fully works in linux kernel.

Thank you very much. Let me know if it's worth to provide more information on the question.

Your Email:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 13 plus 2?