From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756079Ab0JROEu (ORCPT ); Mon, 18 Oct 2010 10:04:50 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:33887 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755979Ab0JROEs (ORCPT ); Mon, 18 Oct 2010 10:04:48 -0400 From: Julia Lawall To: Liam Girdwood Cc: kernel-janitors@vger.kernel.org, Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error code in failure Date: Mon, 18 Oct 2010 16:11:13 +0200 Message-Id: <1287411074-19825-1-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this code, 0 is returned on failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @a@ identifier alloc; identifier ret; constant C; expression x; @@ x = alloc(...); if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> } @@ identifier f, a.alloc; expression ret; expression x,e1,e2,e3; @@ ret = 0 ... when != ret = e1 *x = alloc(...) ... when != ret = e2 if (x == NULL) { ... when != ret = e3 return ret; } // Signed-off-by: Julia Lawall --- Another call to platform_get_resource in the same function returns -ENODEV on error, so I have used that value. sound/soc/davinci/davinci-mcasp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index c8e97dc..86918ee 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -898,6 +898,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { dev_err(&pdev->dev, "no DMA resource\n"); + ret = -ENODEV; goto err_release_region; } @@ -912,6 +913,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_DMA, 1); if (!res) { dev_err(&pdev->dev, "no DMA resource\n"); + ret = -ENODEV; goto err_release_region; }