Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:48:56+00:00 2026-06-13T00:48:56+00:00

the device driver I’m working on is implementing a virtual device. The logic is

  • 0

the device driver I’m working on is implementing a virtual device. The logic
is as follows:

static struct net_device_ops virt_net_ops = {
  .ndo_init = virt_net_init,
  .ndo_open = virt_net_open,
  .ndo_stop = virt_net_stop,
  .ndo_do_ioctl = virt_net_ioctl,
  .ndo_get_stats    = virt_net_get_stats,
  .ndo_start_xmit   = virt_net_start_xmit,
};

...

  struct net_device *dev;
  struct my_dev *virt;

  dev = alloc_netdev(..);
  /* check for NULL */

  virt = netdev_priv(dev);

  dev->netdev_ops = &virt_net_ops;
  SET_ETHTOOL_OPS(dev, &virt_ethtool_ops);
  dev_net_set(dev, net);
  virt->magic = MY_VIRT_DEV_MAGIC;
  ret = register_netdev(dev);
  if (ret) {
     printk("register_netdev failed\n");
     free_netdev(dev);
     return ret;
  }
...

What happens is that somewhere somehow the pointer net_device_ops in
‘net_dev’ gets corrupted, i.e.

1) create the device the first time (allocated net_dev, init the fields
including net_device_ops,which is
initialized with a static structure containing function pointers), register
the device with the kernel invoking register_netdev() – OK

2) attempt to create the device with the same name again, repeat the above
steps, call register_netdev() which will return negative and we
free_netdev(dev) and return error to the caller.

And between these two events the pointer to net_device_ops has changed,
although nowhere in the code it is done explicitly except the initialization
phase.

The kernel version is 2.6.31.8, platform MIPS. Communication channel between the user space and the kernel is implemented via netlink sockets.

Could anybody suggest what possibly can go wrong?
Appreciate any advices, thanks.

Mark

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:48:57+00:00Added an answer on June 13, 2026 at 12:48 am

    “The bug is somewhere else. “

    The second device should not interact with the existing one. If you register_netdev with an existing name, nevertheless the ndo_init virtual function is called first before the condition is detected and -EEXIST is returned. Maybe your init function does something nasty involving some global variables. (For example, does the code assume there is one device, and stash a global pointer to it during initialization?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading through the network device driver code.My driver follows the driver-model.REF:kernel/Documentation/driver-model. Reading
I have some homework which I should program a virtual device driver on kernel
I have written a PCIe device driver and the read/write functions are not working
We're working on a device driver for Vista. There's a known bug in SPO
How to write simpliest audio virtual device driver in WinXP? I know that one
I'm implementing a ioctl in a Windows CE device driver that takes a pointer
I am reading linux device driver book of rubini,corbet and hartmen.I have doubt regarding
I am rather new to Linux device driver programmring, but for debugging purposes, I
i have to make a device driver that returns a random number between 1
I am adding some code to an existing FreeBSD device driver and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.