Re: [PATCH] missing NULL check in drivers/char/n_tty.c

From: Paul Fulghum (paulkf_at_microgate.com)
Date: 06/21/04

  • Next message: Stephen C. Tweedie: "Re: [2.4] page->buffers vanished in journal_try_to_free_buffers()"
    Date:	Mon, 21 Jun 2004 10:06:46 -0500
    To: Dan Aloni <da-x@colinux.org>
    
    

    Dan Aloni wrote:
    > Andrew Morton wrote:
    > I did a quick grep and it appears that all drivers have set ->chars_in_buffer().
    >
    > I suspect there are no drivers which fail to set chars_in_buffer.
    > Otherwise normal_poll() would have been oopsing in 2.4, 2.5 and 2.6?

    An addition should be made to include/linux/tty_driver.h
    to document the chars_in_buffer member of struct tty_driver
    and struct tty_operations as a required function.
    Currently, the documentation section of this header
    does not mention chars_in_buffer.

    Related issue:

    In looking at this, I noticed struct tty_ldisc
    (include/linux/tty_ldisc.h) defines and documents
    an optional (optional == NULL) member chars_in_buffer.
    N_TTY (drivers/char/n_tty.c) is the only line discipline
    that implements this member.

    drivers/char/pty.c is the only driver that
    uses ldisc.chars_in_buffer, and it checks for
    ldisc.chars_in_buffer == NULL before calling.

    13 other drivers call ldisc.chars_in_buffer without checking
    for ldisc.chars_in_buffer == NULL, but only inside conditional
    compilation for debug output. The value is not used, only logged.
    These conditional debug items look like cut and paste from
    one serial driver to another, and I doubt
    they have been recently used (or used at all).

    Which would be better?
    1. Ignore this
    2. Fix conditional debug output to check
        for ldisc.chars_in_buffer==NULL
    3. Remove conditional debug output

    --
    Paul Fulghum
    paulkf@microgate.com
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Stephen C. Tweedie: "Re: [2.4] page->buffers vanished in journal_try_to_free_buffers()"

    Relevant Pages

    • Re: Requesting sample code!
      ... a function can never be a member of a struct. ... Putting a pointer to function in a structure is no different. ... than a pointer to int or pointer to char or pointer to struct. ...
      (microsoft.public.vc.language)
    • Re: What do others make of this code?
      ... The intent of the 'm_' is to distinguish the variable as a member ... I also didn't like the "m_" prefix. ... C++ programming guidelines. ... It all depends IMHO on how the struct is used. ...
      (comp.lang.cpp)
    • Re: realloc() implicit free() ?
      ... >>> memory has no effective type, because it hasn't been stored into yet. ... Writing into one struct member causes the whole struct to be accessed ... >>> pointers to structs being the same as pointers to their first ...
      (comp.lang.c)
    • PP installation failed in Sun One Web Server
      ... member of struct or union. ... t #1 is not the correct type. ...
      (php.general)
    • Re: Uninitialized memory, malloc and unsigned char
      ... the structure or union object may be a trap representation. ... affect validity of the struct. ... undefined behavior even when the member of a struct being assigned ... the array it points to may be used instead of a buffer allocated by ...
      (comp.std.c)