Re: segfault while trying to upgrade kernel module to 2.6 char-dev-driver API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Cromie wrote:


attached is a cut-down patch that attempts to convert scx200_gpio
to use the new 2.6 char-dev-driver API.
Its closely modelled after LDD-3 scull driver.

it segfaults reliably on cat /proc/devices after rmmod'g
tested against 12-rc4-mm2, I think it will apply to 12-rc[45]


#!/bin/bash

# load 1 at a time ??
modprobe scx200
modprobe scx200_gpio

cat /proc/devices

rmmod scx200_gpio
cat /proc/devices    # 1st segfault here

rmmod scx200
cat /proc/devices    # segfault again here


I can hazard a few (blind) guesses as to the reasons for segfault:

1.  Im doing it wrong (I did check for the obvious, but..)
2.  this is a mixed conversion
scx200_gpio depends upon scx200, which is still old api, I havent touched it.

tia
jimc


well, it was 1, my bug.  Heres the fix.

$ diff diff.scx200-segfault.20050603.0*
3c3
< +++ scx200-segfault/drivers/char/scx200_gpio.c 2005-05-30 08:45:38.000000000 -0600
---
> +++ scx200-segfault/drivers/char/scx200_gpio.c 2005-06-03 09:12:18.000000000 -0600
103c103
< +     unregister_chrdev_region(devno, MAX_MINORS);
---
> +     unregister_chrdev_region(devno, NR_DEVS);


Even though this is kernel prgramming, it strikes me that there might be
room for improvement wrt protecting the OS from chr-driver programming errors.

It might be low-hanging fruit for one of the taller newbies (taller than myself ;-)
Any giants care to comment ?


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux