diff mbox

net: ieee802154: mcr20a: do not leak resources on error path

Message ID 20180412122849.15329-1-stefan@osg.samsung.com
State Accepted
Headers show

Commit Message

Stefan Schmidt April 12, 2018, 12:28 p.m. UTC
We already allocated the device and platform  data at this
point. Instead of simply return from the probe function we
need to cleanup the resources first.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/mcr20a.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Xue Liu April 12, 2018, 12:38 p.m. UTC | #1
ACK-by: Xue Liu <liuxuenetmail@gmail.com>

On 12 April 2018 at 14:28, Stefan Schmidt <stefan@osg.samsung.com> wrote:
> We already allocated the device and platform  data at this
> point. Instead of simply return from the probe function we
> need to cleanup the resources first.
>
> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
> ---
>  drivers/net/ieee802154/mcr20a.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index 944470d69ba9..de0d7f28a181 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -1309,8 +1309,10 @@ mcr20a_probe(struct spi_device *spi)
>         /* init buf */
>         lp->buf = devm_kzalloc(&spi->dev, SPI_COMMAND_BUFFER, GFP_KERNEL);
>
> -       if (!lp->buf)
> -               return -ENOMEM;
> +       if (!lp->buf) {
> +               ret = -ENOMEM;
> +               goto free_dev;
> +       }
>
>         mcr20a_setup_tx_spi_messages(lp);
>         mcr20a_setup_rx_spi_messages(lp);
> --
> 2.14.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stefan Schmidt April 12, 2018, 1:23 p.m. UTC | #2
Hello Xue.


On 04/12/2018 02:38 PM, Xue Liu wrote:
> ACK-by: Xue Liu <liuxuenetmail@gmail.com>

Same as with your last ACK thsi is the wrong format.

I explained in the last mail the details. Please have nother read and send a correct Acked-By

line so patchwork can pick it up and it will be present in the commit when I test and push it.


regards
Stefan Schmidt
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xue Liu April 12, 2018, 1:27 p.m. UTC | #3
Hello Stefan,

Thanks for the reminder. I will send a new one.

Regards,

Xue Liu

On 12 April 2018 at 15:23, Stefan Schmidt <stefan@osg.samsung.com> wrote:
> Hello Xue.
>
>
> On 04/12/2018 02:38 PM, Xue Liu wrote:
>> ACK-by: Xue Liu <liuxuenetmail@gmail.com>
>
> Same as with your last ACK thsi is the wrong format.
>
> I explained in the last mail the details. Please have nother read and send a correct Acked-By
>
> line so patchwork can pick it up and it will be present in the commit when I test and push it.
>
>
> regards
> Stefan Schmidt
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xue Liu April 12, 2018, 1:28 p.m. UTC | #4
Acked-by: Xue Liu <liuxuenetmail@gmail.com>

On 12 April 2018 at 14:28, Stefan Schmidt <stefan@osg.samsung.com> wrote:
> We already allocated the device and platform  data at this
> point. Instead of simply return from the probe function we
> need to cleanup the resources first.
>
> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
> ---
>  drivers/net/ieee802154/mcr20a.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index 944470d69ba9..de0d7f28a181 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -1309,8 +1309,10 @@ mcr20a_probe(struct spi_device *spi)
>         /* init buf */
>         lp->buf = devm_kzalloc(&spi->dev, SPI_COMMAND_BUFFER, GFP_KERNEL);
>
> -       if (!lp->buf)
> -               return -ENOMEM;
> +       if (!lp->buf) {
> +               ret = -ENOMEM;
> +               goto free_dev;
> +       }
>
>         mcr20a_setup_tx_spi_messages(lp);
>         mcr20a_setup_rx_spi_messages(lp);
> --
> 2.14.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stefan Schmidt April 13, 2018, 8:49 a.m. UTC | #5
Hello.


On 04/12/2018 03:28 PM, Xue Liu wrote:
> Acked-by: Xue Liu <liuxuenetmail@gmail.com>

Thanks for the review, Xue.

>
> On 12 April 2018 at 14:28, Stefan Schmidt <stefan@osg.samsung.com> wrote:
>> We already allocated the device and platform  data at this
>> point. Instead of simply return from the probe function we
>> need to cleanup the resources first.
>>
>> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
>> ---
>>  drivers/net/ieee802154/mcr20a.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
>> index 944470d69ba9..de0d7f28a181 100644
>> --- a/drivers/net/ieee802154/mcr20a.c
>> +++ b/drivers/net/ieee802154/mcr20a.c
>> @@ -1309,8 +1309,10 @@ mcr20a_probe(struct spi_device *spi)
>>         /* init buf */
>>         lp->buf = devm_kzalloc(&spi->dev, SPI_COMMAND_BUFFER, GFP_KERNEL);
>>
>> -       if (!lp->buf)
>> -               return -ENOMEM;
>> +       if (!lp->buf) {
>> +               ret = -ENOMEM;
>> +               goto free_dev;
>> +       }
>>
>>         mcr20a_setup_tx_spi_messages(lp);
>>         mcr20a_setup_rx_spi_messages(lp);
>> --
>> 2.14.3
>>
This patch has been applied to the wpan tree and will be
part of the next pull request to net.

regards
Stefan Schmidt
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" 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/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index 944470d69ba9..de0d7f28a181 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -1309,8 +1309,10 @@  mcr20a_probe(struct spi_device *spi)
 	/* init buf */
 	lp->buf = devm_kzalloc(&spi->dev, SPI_COMMAND_BUFFER, GFP_KERNEL);
 
-	if (!lp->buf)
-		return -ENOMEM;
+	if (!lp->buf) {
+		ret = -ENOMEM;
+		goto free_dev;
+	}
 
 	mcr20a_setup_tx_spi_messages(lp);
 	mcr20a_setup_rx_spi_messages(lp);