All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gen Zhang <blackgod016574@gmail.com>
To: ssantosh@kernel.org, marc.zyngier@arm.com, olof@lixom.net
Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] knav_qmss_queue: fix a missing-check bug in knav_pool_create()
Date: Tue, 11 Jun 2019 02:37:44 -0700	[thread overview]
Message-ID: <20190611093744.GA9783@ubuntu> (raw)
In-Reply-To: <20190530033949.GA8895@zhanggen-UX430UQ>

On Thu, May 30, 2019 at 11:39:49AM +0800, Gen Zhang wrote:
> In knav_pool_create(), 'pool->name' is allocated by kstrndup(). It
> returns NULL when fails. So 'pool->name' should be checked. And free
> 'pool' when error.
> 
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> ---
> diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
> index 8b41837..0f8cb28 100644
> --- a/drivers/soc/ti/knav_qmss_queue.c
> +++ b/drivers/soc/ti/knav_qmss_queue.c
> @@ -814,6 +814,12 @@ void *knav_pool_create(const char *name,
>  	}
>  
>  	pool->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL);
> +	if (!pool->name) {
> +		dev_err(kdev->dev, "failed to duplicate for pool(%s)\n",
> +			name);
> +		ret = -ENOMEM;
> +		goto err_name;
> +	}
>  	pool->kdev = kdev;
>  	pool->dev = kdev->dev;
>  
> @@ -864,6 +870,7 @@ void *knav_pool_create(const char *name,
>  	mutex_unlock(&knav_dev_lock);
>  err:
>  	kfree(pool->name);
> +err_name:
>  	devm_kfree(kdev->dev, pool);
>  	return ERR_PTR(ret);
>  }
Can anyone look into this patch?

Thanks
Gen

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Gen Zhang <blackgod016574@gmail.com>
To: ssantosh@kernel.org, marc.zyngier@arm.com, olof@lixom.net
Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] knav_qmss_queue: fix a missing-check bug in knav_pool_create()
Date: Tue, 11 Jun 2019 02:37:44 -0700	[thread overview]
Message-ID: <20190611093744.GA9783@ubuntu> (raw)
In-Reply-To: <20190530033949.GA8895@zhanggen-UX430UQ>

On Thu, May 30, 2019 at 11:39:49AM +0800, Gen Zhang wrote:
> In knav_pool_create(), 'pool->name' is allocated by kstrndup(). It
> returns NULL when fails. So 'pool->name' should be checked. And free
> 'pool' when error.
> 
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> ---
> diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
> index 8b41837..0f8cb28 100644
> --- a/drivers/soc/ti/knav_qmss_queue.c
> +++ b/drivers/soc/ti/knav_qmss_queue.c
> @@ -814,6 +814,12 @@ void *knav_pool_create(const char *name,
>  	}
>  
>  	pool->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL);
> +	if (!pool->name) {
> +		dev_err(kdev->dev, "failed to duplicate for pool(%s)\n",
> +			name);
> +		ret = -ENOMEM;
> +		goto err_name;
> +	}
>  	pool->kdev = kdev;
>  	pool->dev = kdev->dev;
>  
> @@ -864,6 +870,7 @@ void *knav_pool_create(const char *name,
>  	mutex_unlock(&knav_dev_lock);
>  err:
>  	kfree(pool->name);
> +err_name:
>  	devm_kfree(kdev->dev, pool);
>  	return ERR_PTR(ret);
>  }
Can anyone look into this patch?

Thanks
Gen

  reply	other threads:[~2019-06-11  9:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30  3:39 [PATCH] knav_qmss_queue: fix a missing-check bug in knav_pool_create() Gen Zhang
2019-05-30  3:39 ` Gen Zhang
2019-06-11  9:37 ` Gen Zhang [this message]
2019-06-11  9:37   ` Gen Zhang
2019-06-11  9:54   ` Marc Zyngier
2019-06-11  9:54     ` Marc Zyngier
2019-06-11 10:08     ` Gen Zhang
2019-06-11 10:08       ` Gen Zhang
2019-06-11 21:10       ` santosh.shilimkar
2019-06-11 21:10         ` santosh.shilimkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190611093744.GA9783@ubuntu \
    --to=blackgod016574@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=olof@lixom.net \
    --cc=ssantosh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.