diff mbox

[RESEND,gpio] gpio-amd8111: check ioport_map return value

Message ID 1420780131-6984-1-git-send-email-varkab@cdac.in
State New, archived
Headers show

Commit Message

Varka Bhadram Jan. 9, 2015, 5:08 a.m. UTC
From: Varka Bhadram <varkabhadram@gmail.com>

ioport_map() may fail. Its safe to check the return value.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/gpio/gpio-amd8111.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Alexandre Courbot Jan. 19, 2015, 6:27 a.m. UTC | #1
On Fri, Jan 9, 2015 at 2:08 PM, Varka Bhadram <varkabhadram@gmail.com> wrote:
> From: Varka Bhadram <varkabhadram@gmail.com>
>
> ioport_map() may fail. Its safe to check the return value.
>
> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> ---
>  drivers/gpio/gpio-amd8111.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
> index d3d2d10..2c4d9ab 100644
> --- a/drivers/gpio/gpio-amd8111.c
> +++ b/drivers/gpio/gpio-amd8111.c
> @@ -213,6 +213,11 @@ found:
>                 goto out;
>         }
>         gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
> +       if (!gp.pm) {
> +               dev_err(&pdev->dev, "Couldn't map io port into io memory\n");
> +               err = -ENOMEM;
> +               goto out;

You are not calling release_region() to free the region requested right above.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Varka Bhadram Jan. 19, 2015, 7:04 a.m. UTC | #2
On Mon, Jan 19, 2015 at 11:57 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Fri, Jan 9, 2015 at 2:08 PM, Varka Bhadram <varkabhadram@gmail.com> wrote:
>> From: Varka Bhadram <varkabhadram@gmail.com>
>>
>> ioport_map() may fail. Its safe to check the return value.
>>
>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>> ---
>>  drivers/gpio/gpio-amd8111.c |    5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
>> index d3d2d10..2c4d9ab 100644
>> --- a/drivers/gpio/gpio-amd8111.c
>> +++ b/drivers/gpio/gpio-amd8111.c
>> @@ -213,6 +213,11 @@ found:
>>                 goto out;
>>         }
>>         gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
>> +       if (!gp.pm) {
>> +               dev_err(&pdev->dev, "Couldn't map io port into io memory\n");
>> +               err = -ENOMEM;
>> +               goto out;
>
> You are not calling release_region() to free the region requested right above.

Yes... You are correct. I will send the patch for this. Can i add
Reported-by tag of your..?
Alexandre Courbot Jan. 19, 2015, 7:48 a.m. UTC | #3
On Mon, Jan 19, 2015 at 4:04 PM, Varka Bhadram <varkabhadram@gmail.com> wrote:
> On Mon, Jan 19, 2015 at 11:57 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
>> On Fri, Jan 9, 2015 at 2:08 PM, Varka Bhadram <varkabhadram@gmail.com> wrote:
>>> From: Varka Bhadram <varkabhadram@gmail.com>
>>>
>>> ioport_map() may fail. Its safe to check the return value.
>>>
>>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>>> ---
>>>  drivers/gpio/gpio-amd8111.c |    5 +++++
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
>>> index d3d2d10..2c4d9ab 100644
>>> --- a/drivers/gpio/gpio-amd8111.c
>>> +++ b/drivers/gpio/gpio-amd8111.c
>>> @@ -213,6 +213,11 @@ found:
>>>                 goto out;
>>>         }
>>>         gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
>>> +       if (!gp.pm) {
>>> +               dev_err(&pdev->dev, "Couldn't map io port into io memory\n");
>>> +               err = -ENOMEM;
>>> +               goto out;
>>
>> You are not calling release_region() to free the region requested right above.
>
> Yes... You are correct. I will send the patch for this. Can i add
> Reported-by tag of your..?

Ah, I did not notice that Linus had already merged this. Sure, feel
free to do so.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
index d3d2d10..2c4d9ab 100644
--- a/drivers/gpio/gpio-amd8111.c
+++ b/drivers/gpio/gpio-amd8111.c
@@ -213,6 +213,11 @@  found:
 		goto out;
 	}
 	gp.pm = ioport_map(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE);
+	if (!gp.pm) {
+		dev_err(&pdev->dev, "Couldn't map io port into io memory\n");
+		err = -ENOMEM;
+		goto out;
+	}
 	gp.pdev = pdev;
 	gp.chip.dev = &pdev->dev;