linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] DMA: PL330: Fix potential NULL pointer dereference in pl330_submit_req()
@ 2012-09-17  9:50 Sachin Kamat
  2012-09-17  9:50 ` [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc Sachin Kamat
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin Kamat @ 2012-09-17  9:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: vinod.koul, jassisinghbrar, sachin.kamat, patches

'r->cfg' is being checked for NULL. However, it is dereferenced
in the previous statements. Thus moving those statements within
the check.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/dma/pl330.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 2343d7d..018a445 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r)
 		goto xfer_exit;
 	}
 
-	/* Prefer Secure Channel */
-	if (!_manager_ns(thrd))
-		r->cfg->nonsecure = 0;
-	else
-		r->cfg->nonsecure = 1;
 
 	/* Use last settings, if not provided */
-	if (r->cfg)
+	if (r->cfg) {
+		/* Prefer Secure Channel */
+		if (!_manager_ns(thrd))
+			r->cfg->nonsecure = 0;
+		else
+			r->cfg->nonsecure = 1;
+
 		ccr = _prepare_ccr(r->cfg);
-	else
+	} else {
 		ccr = readl(regs + CC(thrd->id));
+	}
 
 	/* If this req doesn't have valid xfer settings */
 	if (!_is_valid(ccr)) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc
  2012-09-17  9:50 [PATCH 1/2] DMA: PL330: Fix potential NULL pointer dereference in pl330_submit_req() Sachin Kamat
@ 2012-09-17  9:50 ` Sachin Kamat
  2012-09-17 11:59   ` Jassi Brar
  2012-09-18  3:36   ` Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Sachin Kamat @ 2012-09-17  9:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: vinod.koul, jassisinghbrar, sachin.kamat, patches

kzalloc could return NULL. Hence add a check to avoid
NULL pointer dereference.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/dma/pl330.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 018a445..5d3bbcd 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2930,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
 
 	pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
+	if (!pdmac->peripherals) {
+		ret = -ENOMEM;
+		dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
+		goto probe_err5;
+	}
 
 	for (i = 0; i < num_chan; i++) {
 		pch = &pdmac->peripherals[i];
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc
  2012-09-17  9:50 ` [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc Sachin Kamat
@ 2012-09-17 11:59   ` Jassi Brar
  2012-09-18  3:36   ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Jassi Brar @ 2012-09-17 11:59 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-kernel, vinod.koul, patches

On Mon, Sep 17, 2012 at 3:20 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> kzalloc could return NULL. Hence add a check to avoid
> NULL pointer dereference.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Patch 1 and 2, both
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc
  2012-09-17  9:50 ` [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc Sachin Kamat
  2012-09-17 11:59   ` Jassi Brar
@ 2012-09-18  3:36   ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2012-09-18  3:36 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-kernel, jassisinghbrar, patches

On Mon, 2012-09-17 at 15:20 +0530, Sachin Kamat wrote:
> kzalloc could return NULL. Hence add a check to avoid
> NULL pointer dereference.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/dma/pl330.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index 018a445..5d3bbcd 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -2930,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>  		num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
>  
>  	pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
> +	if (!pdmac->peripherals) {
> +		ret = -ENOMEM;
> +		dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
> +		goto probe_err5;
> +	}
>  
>  	for (i = 0; i < num_chan; i++) {
>  		pch = &pdmac->peripherals[i];

Thanks applied both to fixes. 
I have cc'ed stable as well

-- 
~Vinod


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-18  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17  9:50 [PATCH 1/2] DMA: PL330: Fix potential NULL pointer dereference in pl330_submit_req() Sachin Kamat
2012-09-17  9:50 ` [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc Sachin Kamat
2012-09-17 11:59   ` Jassi Brar
2012-09-18  3:36   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).