lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a0hR2+g+vxKqm=a8DgPcNrBaqa3sbuEHuVzaw9Fryd4Zg@mail.gmail.com>
Date:   Mon, 8 Jul 2019 17:58:15 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Rex Zhu <rex.zhu@....com>, Evan Quan <evan.quan@....com>,
        Alex Deucher <alexander.deucher@....com>,
        Christian König <christian.koenig@....com>,
        "David (ChunMing) Zhou" <David1.Zhou@....com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        Chengming Gui <Jack.Gui@....com>,
        Kevin Wang <kevin1.wang@....com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        amd-gfx@...ts.freedesktop.org, Huang Rui <ray.huang@....com>,
        dri-devel <dri-devel@...ts.freedesktop.org>,
        Likun Gao <Likun.Gao@....com>,
        Hawking Zhang <Hawking.Zhang@....com>
Subject: Re: [1/2] drm/amd/powerplay: smu_v11_0: fix uninitialized variable use

On Mon, Jul 8, 2019 at 5:02 PM Nathan Chancellor
<natechancellor@...il.com> wrote:
> On Mon, Jul 08, 2019 at 04:07:58PM +0200, Arnd Bergmann wrote:
> >       /* if don't has GetDpmClockFreq Message, try get current clock by SmuMetrics_t */
> > -     if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0)
> > +     if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) {
> >               ret =  smu_get_current_clk_freq_by_table(smu, clk_id, &freq);
> > -     else {
> > +             if (ret)
> > +                     return ret;
>
> I am kind of surprised that this fixes the warning. If I am interpreting
> the warning correctly, it is complaining that the member
> get_current_clk_freq_by_table could be NULL and not be called to
> initialize freq and that entire statement will become 0. If that is the
> case, it seems like this added error handling won't fix that problem,
> right?

No, I'm fairly sure this is the right fix. Looking at the whole function:

| static int smu_v11_0_get_current_clk_freq(struct smu_context *smu,
|                                          enum smu_clk_type clk_id,
|                                          uint32_t *value)
|{
|        int ret = 0;
|        uint32_t freq;
|
|        if (clk_id >= SMU_CLK_COUNT || !value)
|                return -EINVAL;
|
|        /* if don't has GetDpmClockFreq Message, try get current
clock by SmuMetrics_t */
|        if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) {
|                ret =  smu_get_current_clk_freq_by_table(smu, clk_id, &freq);

Here &freq may or may not get initialized

|        } else {
|                ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetDpmClockFreq,
|
(smu_clk_get_index(smu, clk_id) << 16));
|                if (ret)
|                        return ret;
|
|               ret = smu_read_smc_arg(smu, &freq);
|                if (ret)
|                        return ret;

Same here, but if it's not initialized, we bail out

|        }
|
|       freq *= 100;
|        *value = freq;

And here it gets assigned to *value

|        return ret;
|}

    Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ