From patchwork Tue Aug 16 08:44:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9282899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF82A60574 for ; Tue, 16 Aug 2016 08:44:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDEFD28491 for ; Tue, 16 Aug 2016 08:44:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D263D2877E; Tue, 16 Aug 2016 08:44:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A063C28491 for ; Tue, 16 Aug 2016 08:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751870AbcHPIoY (ORCPT ); Tue, 16 Aug 2016 04:44:24 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34901 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbcHPIoX (ORCPT ); Tue, 16 Aug 2016 04:44:23 -0400 Received: by mail-wm0-f66.google.com with SMTP id i5so15168465wmg.2; Tue, 16 Aug 2016 01:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CCL+5lNoveG21jy6k0slHf5m+GjPaeYAkjRhyxzlfBg=; b=y3rrefl4yUsNPtCL2Ys3J1bq6toa6d6zTzxcbCouJXRsJiTaJLCMn/ljdaveevWBQn HDMHTbwpbVM6Efeat08Dwti1oL1C+lLARnegGTpLyiw6qzuW/tdtoIKsSqpJomYQwPOR ngV4KkNBrdI5xOl3dWSMWvD2A/yCinyvU72V5I7Eh1Sz91r4Lmtqo81NKxwdLzgSxJAG BxpI5GoIk6a3TKbtHtUOiJK4/cul6bBIApmLJlD8FfuWqC/st9epnV+hnIYoytXaSHp9 WRUofTc5qLH9Sl4UHHKXoyctiwlnOLkvIcfwisgVs7uyEB2horR9XOtqVseQt/ntgKHR xbTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CCL+5lNoveG21jy6k0slHf5m+GjPaeYAkjRhyxzlfBg=; b=XTjlS7LRn+/afTvnBlCh2LUOqxTRrWik239b+SwDrsuheP41vCgr0d1TChUOymAZVR SF5EY4Z2i+nhVuVVYzFn3s2B2PnzoKHcTTGhCn71ObMka2U4CBJZcOxo6uxGWjZp2j5m dX3jMPpsGimhF8TtMnY/ccosBBSQRZxwSM7Qr97KMdmoLx/p/zoUgdmp6aw+LXVlLjEO GTaEWpUssi2v8k2055OKbzbY4hI/pxkBxpuwM0EQCjTnKB0Rlh3ZeiscnM2spTGERj91 IKubXNdqyWs7LJ/q+q3Aaz3A4exOif7Nfz8LburtpwINMAUKZPl8vqNvfVhns5LFX1+y 8RSg== X-Gm-Message-State: AEkooutrBSkg9p7OPRb6oQ02UA9qWDXjUSSksVR7qUEJk5pM+As2TFQrXkzwxMZtKuqvyg== X-Received: by 10.28.46.204 with SMTP id u195mr19237492wmu.57.1471337061887; Tue, 16 Aug 2016 01:44:21 -0700 (PDT) Received: from Red.local (ANice-651-1-389-119.w86-205.abo.wanadoo.fr. [86.205.21.119]) by smtp.googlemail.com with ESMTPSA id i80sm20566569wmf.11.2016.08.16.01.44.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Aug 2016 01:44:21 -0700 (PDT) From: LABBE Corentin To: vinod.koul@intel.com, dan.j.williams@intel.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, LABBE Corentin Subject: [PATCH] dmaengine: img-mdc: fix a possible NULL dereference Date: Tue, 16 Aug 2016 10:44:18 +0200 Message-Id: <1471337058-15372-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.7.3 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_match_device could return NULL, and so cause a NULL pointer dereference later at line 850: mdma->soc = match->data; For fixing this problem, we use of_device_get_match_data(), this will simplify the code a little by using a standard function for getting the match data. Reported-by: coverity (CID 1324134) Signed-off-by: LABBE Corentin --- drivers/dma/img-mdc-dma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c index a4c53be..624f1e1 100644 --- a/drivers/dma/img-mdc-dma.c +++ b/drivers/dma/img-mdc-dma.c @@ -861,7 +861,6 @@ static int mdc_dma_probe(struct platform_device *pdev) { struct mdc_dma *mdma; struct resource *res; - const struct of_device_id *match; unsigned int i; u32 val; int ret; @@ -871,8 +870,7 @@ static int mdc_dma_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, mdma); - match = of_match_device(mdc_dma_of_match, &pdev->dev); - mdma->soc = match->data; + mdma->soc = of_device_get_match_data(&pdev->dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mdma->regs = devm_ioremap_resource(&pdev->dev, res);