From patchwork Mon May 14 09:11:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10397629 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 922D4600D0 for ; Mon, 14 May 2018 09:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79350290D8 for ; Mon, 14 May 2018 09:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA04290DA; Mon, 14 May 2018 09:11:36 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 00D24290D8 for ; Mon, 14 May 2018 09:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752013AbeENJLf (ORCPT ); Mon, 14 May 2018 05:11:35 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36817 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbeENJLf (ORCPT ); Mon, 14 May 2018 05:11:35 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id ED806207AC; Mon, 14 May 2018 11:11:32 +0200 (CEST) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 990F72071F; Mon, 14 May 2018 11:11:32 +0200 (CEST) From: Boris Brezillon To: Mark Brown , linux-spi@vger.kernel.org Cc: Vignesh R , Dan Carpenter , Boris Brezillon Subject: [PATCH] spi: ti-qspi: Make sure res_mmap != NULL before dereferencing it Date: Mon, 14 May 2018 11:11:29 +0200 Message-Id: <20180514091129.3422-1-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP resource_size() is dereferencing the res without checking that it is not NULL, so we need to do the check before calling resource_size(). Fixes: b95cb394ab59 ("spi: ti-qspi: Implement the spi_mem interface") Reported-by: Dan Carpenter Signed-off-by: Boris Brezillon --- drivers/spi/spi-ti-qspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c index c54b760e00ed..5f19016bbf10 100644 --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c @@ -718,7 +718,9 @@ static int ti_qspi_probe(struct platform_device *pdev) "memory mapped resource not required\n"); } } - qspi->mmap_size = resource_size(res_mmap); + + if (res_mmap) + qspi->mmap_size = resource_size(res_mmap); irq = platform_get_irq(pdev, 0); if (irq < 0) {