[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VeSDFOq18e3NSaHBN-aNvrR5Uj56=AbFrMSAxNkaOT3LA@mail.gmail.com>
Date: Thu, 30 Mar 2017 13:38:43 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Chanwoo Choi <cw00.choi@...sung.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Hans de Goede <hdegoede@...hat.com>, chanwoo@...nel.org,
MyungJoo Ham <myungjoo.ham@...sung.com>
Subject: Re: [PATCH 1/2] extcon: Use BIT() macro for the left-shift operation
On Thu, Mar 30, 2017 at 12:15 PM, Chanwoo Choi <cw00.choi@...sung.com> wrote:
> On 2017년 03월 30일 17:59, Andy Shevchenko wrote:
>> On Thu, Mar 30, 2017 at 11:39 AM, Chanwoo Choi <cw00.choi@...sung.com> wrote:
>>> This patch just uses the BIT() macro to make the code simple.
>>
>>> for (i = 0; i < edev->max_supported; i++) {
>>> count += sprintf(buf + count, "%s=%d\n",
>>> extcon_info[edev->supported_cable[i]].name,
>>> - !!(edev->state & (1 << i)));
>>> + !!(edev->state & BIT(i)));
>>> }
>>
>> While change is okay, the above code is fragile. There is a potential
>> buffer overflow.
>
> When extcon device is registered, extcon_dev_register() check a number of
> supported external connectors. The maximum number of supported connectors
> is 32. There is no buffer overflow.
Is there any limit for name? No, there is not (const char *name).
Though for now it is quite unlikely to have the issue.
Feel free to proceed despite my comment.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists