• Himangi Saraogi's avatar
    mfd: menelaus: Remove null pointer dereference · e0c8a1f5
    Himangi Saraogi authored
    If vtg is NULL, it is not possible to access its mode_reg field. At all
    sites where the static function menelaus_set_voltage is called, the first
    argument is the address of a structure defined in the file. So, the null
    test is unnecessary and is removed. Also, a label is done away with.
    
    This problem was found using the following Coccinelle semantic match:
    
    // <smpl>
    @@
    expression E, E1;
    identifier f;
    statement S1,S2,S3;
    @@
    
    * if (E == NULL)
    {
      ... when != if (E == NULL) S1 else S2
          when != E = E1
    * E->f
      ... when any
      return ...;
    }
    else S3
    // </smpl>
    Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
    Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
    Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
    e0c8a1f5
menelaus.c 30.6 KB