diff mbox

ASoC: txx9aclc_ac97: Fix kernel crash on probe

Message ID 1392492509-29426-1-git-send-email-shc_work@mail.ru (mailing list archive)
State Accepted
Headers show

Commit Message

Alexander Shiyan Feb. 15, 2014, 7:28 p.m. UTC
This patch fixes a crash caused by commit af5b2d7519
(ASoC: txx9aclc_ac97: Convert to devm_ioremap_resource()).
This is an attempt to assign "drvdata->base" while memory
for "drvdata" is not already allocated.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 sound/soc/txx9/txx9aclc-ac97.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Mark Brown Feb. 16, 2014, 12:36 a.m. UTC | #1
On Sat, Feb 15, 2014 at 11:28:29PM +0400, Alexander Shiyan wrote:
> This patch fixes a crash caused by commit af5b2d7519
> (ASoC: txx9aclc_ac97: Convert to devm_ioremap_resource()).
> This is an attempt to assign "drvdata->base" while memory
> for "drvdata" is not already allocated.

Applied, thanks.
Mark Brown Feb. 16, 2014, 12:38 a.m. UTC | #2
On Sat, Feb 15, 2014 at 11:28:29PM +0400, Alexander Shiyan wrote:
> This patch fixes a crash caused by commit af5b2d7519
> (ASoC: txx9aclc_ac97: Convert to devm_ioremap_resource()).
> This is an attempt to assign "drvdata->base" while memory
> for "drvdata" is not already allocated.

I don't know where you got that hash from by the way, that commit isn't
present in mainline?
Alexander Shiyan Feb. 16, 2014, 2:55 a.m. UTC | #3
???????????, 16 ??????? 2014, 8:38 +08:00 ?? Mark Brown <broonie@kernel.org>:
> On Sat, Feb 15, 2014 at 11:28:29PM +0400, Alexander Shiyan wrote:
> > This patch fixes a crash caused by commit af5b2d7519
> > (ASoC: txx9aclc_ac97: Convert to devm_ioremap_resource()).
> > This is an attempt to assign "drvdata->base" while memory
> > for "drvdata" is not already allocated.
> 
> I don't know where you got that hash from by the way, that commit isn't
> present in mainline?

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/sound/soc/txx9/txx9aclc-ac97.c?id=3bed3344c82623f6a37f3032e307d9af5b2d7519

---
Mark Brown Feb. 18, 2014, 1:18 a.m. UTC | #4
On Sun, Feb 16, 2014 at 06:55:53AM +0400, Alexander Shiyan wrote:
> ???????????, 16 ??????? 2014, 8:38 +08:00 ?? Mark Brown <broonie@kernel.org>:
> > On Sat, Feb 15, 2014 at 11:28:29PM +0400, Alexander Shiyan wrote:
> > > This patch fixes a crash caused by commit af5b2d7519

> > I don't know where you got that hash from by the way, that commit isn't
> > present in mainline?

> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/sound/soc/txx9/txx9aclc-ac97.c?id=3bed3344c82623f6a37f3032e307d9af5b2d7519

A shortened commit ID is the *start* of the ID, not the end.  Try
running 'git show af5b2d7519'.
diff mbox

Patch

diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c
index e0305a1..9edd68d 100644
--- a/sound/soc/txx9/txx9aclc-ac97.c
+++ b/sound/soc/txx9/txx9aclc-ac97.c
@@ -183,14 +183,16 @@  static int txx9aclc_ac97_dev_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drvdata->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(drvdata->base))
 		return PTR_ERR(drvdata->base);
 
-	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
 	platform_set_drvdata(pdev, drvdata);
 	drvdata->physbase = r->start;
 	if (sizeof(drvdata->physbase) > sizeof(r->start) &&