diff mbox

ASoC: samsung-i2s: Check secondary DAI exists before referencing

Message ID 1410277909-27922-1-git-send-email-ckeepax@opensource.wolfsonmicro.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Charles Keepax Sept. 9, 2014, 3:51 p.m. UTC
In a couple of places the driver is missing a check to ensure there is a
secondary DAI before it de-references the pointer to it, causing a null
pointer de-reference. This patch adds a check to avoid this.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/samsung/i2s.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

On 09/09/14 17:51, Charles Keepax wrote:
> In a couple of places the driver is missing a check to ensure there is a
> secondary DAI before it de-references the pointer to it, causing a null
> pointer de-reference. This patch adds a check to avoid this.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

Thanks for the patch. We had one of those occurrences fixed internally
but I missed to submit the patch upstream.




--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Sept. 9, 2014, 5:09 p.m. UTC | #2
On Tue, Sep 09, 2014 at 04:51:49PM +0100, Charles Keepax wrote:
> In a couple of places the driver is missing a check to ensure there is a
> secondary DAI before it de-references the pointer to it, causing a null
> pointer de-reference. This patch adds a check to avoid this.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 03eec22..9d51347 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -462,7 +462,7 @@  static int i2s_set_sysclk(struct snd_soc_dai *dai,
 		if (dir == SND_SOC_CLOCK_IN)
 			rfs = 0;
 
-		if ((rfs && other->rfs && (other->rfs != rfs)) ||
+		if ((rfs && other && other->rfs && (other->rfs != rfs)) ||
 				(any_active(i2s) &&
 				(((dir == SND_SOC_CLOCK_IN)
 					&& !(mod & MOD_CDCLKCON)) ||
@@ -762,7 +762,8 @@  static void i2s_shutdown(struct snd_pcm_substream *substream,
 	} else {
 		u32 mod = readl(i2s->addr + I2SMOD);
 		i2s->cdclk_out = !(mod & MOD_CDCLKCON);
-		other->cdclk_out = i2s->cdclk_out;
+		if (other)
+			other->cdclk_out = i2s->cdclk_out;
 	}
 	/* Reset any constraint on RFS and BFS */
 	i2s->rfs = 0;