tech-kern archive

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

Re: Kernel doesn't call spi driver's _match() and _attach()



On Mon, Sep 16, 2024 at 23:16:18 +0300, Nikita Donskov wrote:

> During open("/dev/mydev0", O_RDONLY) call no errors occured.  But
> when I tried to perform one of ioctls from userland, I got invalid
> memory access error in the very beginning of mydev_ioctl().

Since your driver's attach was never called, your mydev_open should
have never returned success.  sc = device_lookup_private in mydev_open
should have returned null to you and your open should detect that and
fail:

        if (sc == NULL)
                return ENXIO;


> int
> mydev_ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *lwp)
> {
> 	struct mydev_softc *sc;
> 	sc = device_lookup_private(&mydev_cd, minor(dev)); /* BANG! */
> 	...

It's likely it goes bang a bit further down, b/c you didn't check that
sc is valid?  Again, sc should have been NULL here and the driver
should check that.


-uwe


Home | Main Index | Thread Index | Old Index