lkml.org 
[lkml]   [2016]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer
    Date
    On Tuesday 16 February 2016 18:26:09 Arnd Bergmann wrote:
    > > return err;
    > > per_pin->acomp_jack = jack;
    > > - jack->private_data = per_pin;
    > > - jack->private_free = free_acomp_jack_priv;
    > > + if (jack) {
    > > + jack->private_data = per_pin;
    > > + jack->private_free = free_acomp_jack_priv;
    > > + }
    > > return 0;
    > > }
    > >
    > Looks good to me.
    >
    > Acked-by: Arnd Bergmann <arnd@arndb.de>
    >

    Actually, on second thought, there is one notable downside
    of this approach: 'jack' is guaranteed to be NULL here, so gcc
    won't produce a warning if another driver makes the same mistake:

    By default, we only get a warning for uses of uninitialized
    variables, but not those that are known to be NULL. I think
    some compiler warnings are able to warn about that too, but I
    forgot the details.

    Arnd

    \
     
     \ /
      Last update: 2016-02-16 23:21    [W:2.851 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site