All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8962: Fix null pointer pdata access in I2C probe()
@ 2013-10-29  9:06 Nicolin Chen
  2013-10-29 16:35 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolin Chen @ 2013-10-29  9:06 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, patches

When using DT binding to pass private data, there would be Kernel panic
occuring due to NULL pointer access in wm8962_i2c_probe(). Thus fix it.

Signed-off-by: Nicolin Chen <b42378@freescale.com>
---
 sound/soc/codecs/wm8962.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 2bf9ee7..7dd79c4 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3616,28 +3616,28 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
 			   0);
 
 	/* Apply static configuration for GPIOs */
-	for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
-		if (pdata->gpio_init[i]) {
+	for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++)
+		if (wm8962->pdata.gpio_init[i]) {
 			wm8962_set_gpio_mode(wm8962, i + 1);
 			regmap_write(wm8962->regmap, 0x200 + i,
-				     pdata->gpio_init[i] & 0xffff);
+				     wm8962->pdata.gpio_init[i] & 0xffff);
 		}
 
 
 	/* Put the speakers into mono mode? */
-	if (pdata->spk_mono)
+	if (wm8962->pdata.spk_mono)
 		regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2,
 				   WM8962_SPK_MONO_MASK, WM8962_SPK_MONO);
 
 	/* Micbias setup, detection enable and detection
 	 * threasholds. */
-	if (pdata->mic_cfg)
+	if (wm8962->pdata.mic_cfg)
 		regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
 				   WM8962_MICDET_ENA |
 				   WM8962_MICDET_THR_MASK |
 				   WM8962_MICSHORT_THR_MASK |
 				   WM8962_MICBIAS_LVL,
-				   pdata->mic_cfg);
+				   wm8962->pdata.mic_cfg);
 
 	/* Latch volume update bits */
 	regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME,
@@ -3682,7 +3682,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
 	}
 
 	if (wm8962->irq) {
-		if (pdata->irq_active_low) {
+		if (wm8962->pdata.irq_active_low) {
 			trigger = IRQF_TRIGGER_LOW;
 			irq_pol = WM8962_IRQ_POL;
 		} else {
-- 
1.8.4

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

* Re: [PATCH] ASoC: wm8962: Fix null pointer pdata access in I2C probe()
  2013-10-29  9:06 [PATCH] ASoC: wm8962: Fix null pointer pdata access in I2C probe() Nicolin Chen
@ 2013-10-29 16:35 ` Mark Brown
  2013-10-30  1:31   ` Nicolin Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2013-10-29 16:35 UTC (permalink / raw)
  To: Nicolin Chen; +Cc: alsa-devel, patches


[-- Attachment #1.1: Type: text/plain, Size: 513 bytes --]

On Tue, Oct 29, 2013 at 05:06:27PM +0800, Nicolin Chen wrote:
> When using DT binding to pass private data, there would be Kernel panic
> occuring due to NULL pointer access in wm8962_i2c_probe(). Thus fix it.

Applied, thanks, so it makes v3.13 though...

> -	for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
> -		if (pdata->gpio_init[i]) {
> +	for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++)
> +		if (wm8962->pdata.gpio_init[i]) {

...it'd be neater to just ensure that pdata is always initialised.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: wm8962: Fix null pointer pdata access in I2C probe()
  2013-10-29 16:35 ` Mark Brown
@ 2013-10-30  1:31   ` Nicolin Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolin Chen @ 2013-10-30  1:31 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches

On Tue, Oct 29, 2013 at 09:35:56AM -0700, Mark Brown wrote:
> > -	for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
> > -		if (pdata->gpio_init[i]) {
> > +	for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++)
> > +		if (wm8962->pdata.gpio_init[i]) {
> 
> ...it'd be neater to just ensure that pdata is always initialised.

I considered about that, and the patch could be neater. But then I
just found the code around this part are all using wm8962>pdata.*
pattern. So I stick the modification to it.

Thank you,
Nicolin Chen

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

end of thread, other threads:[~2013-10-30  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-29  9:06 [PATCH] ASoC: wm8962: Fix null pointer pdata access in I2C probe() Nicolin Chen
2013-10-29 16:35 ` Mark Brown
2013-10-30  1:31   ` Nicolin Chen

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.