From patchwork Mon Jul 31 04:31:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 9870845 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 CECB26038F for ; Mon, 31 Jul 2017 04:32:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C061528537 for ; Mon, 31 Jul 2017 04:32:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4C6228545; Mon, 31 Jul 2017 04:32:24 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F01828537 for ; Mon, 31 Jul 2017 04:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/52T4voU2YMRpVA+2oxQKmNuLQCQXFah2eishl+e9+0=; b=DMvIiVGO3Bv4gz niQKfmeU5qYoBxPbY1/Mf7mml8gJV2l4CAq2BrFNjy2rvtl3YKQ2tgQWmP8ArVN1wZN2BT2cIKO4V eUxTbNB/2NMKJ6MOJ0rDndUsdyYtlIDu8kB2JJye2OtHZ5vMVfPQLcvr02CVQ3W9jOa25/4Xqwlzu soTVHh5voMZ+3sn13rqh/skdn9HisePUwgMz5JGwcN4zJorWsj6WjGfll2n+NvwdLOrzQrbiJ6iOV xs7VE+dh8ZuxdKT+ehO0yNNcGCsi9/vwJdkoCXWcWRX2Dj2UClM3Fmhjmlhw7G8K2rRpiN/bLcRWR VIOAvGm5emHoEqOhCdyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dc2NI-0003mZ-Sm; Mon, 31 Jul 2017 04:32:12 +0000 Received: from lelnx194.ext.ti.com ([198.47.27.80]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dc2NF-0003ls-5t for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2017 04:32:11 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v6V4VgV1023578; Sun, 30 Jul 2017 23:31:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1501475502; bh=SjvZYKSULEeK2v+jgKW1MdfsXONY5h65K95OdUb56AE=; h=From:To:CC:Subject:Date; b=yECAVwFT4xIxRHpYBU75Cx6kZCJXlQ8Vr0MdLYGCk09jDArGSY3OmRH/3Cn/dP8ua hmGd1basX5HpmKkC9FUqXtRJRiWmNEaHsoQz14YChMh4zV6yJMEEoWukEpjmAjTsrM 4taCniYGiFpnEU5Zc9RdX98Y73A0c+1SaLOoDRnU= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6V4VgB2000446; Sun, 30 Jul 2017 23:31:42 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Sun, 30 Jul 2017 23:31:41 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6V4VdOG007077; Sun, 30 Jul 2017 23:31:40 -0500 From: Keerthy To: , Subject: [PATCH v2] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create Date: Mon, 31 Jul 2017 10:01:36 +0530 Message-ID: <1501475496-10267-1-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170730_213209_374216_E3C34812 X-CRM114-Status: UNSURE ( 6.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: t-kristo@ti.com, j-keerthy@ti.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP knav_pool_create is an exported function. In the event of a call before knav_queue_probe, we encounter a NULL pointer dereference in the following line. Hence return -EPROBE_DEFER to the caller till the kdev pointer is non-NULL. Signed-off-by: Keerthy --- Changes in v2: * Fixed returning an int to returning pointer. drivers/soc/ti/knav_qmss_queue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 279e7c5..d91626b 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -745,6 +745,9 @@ void *knav_pool_create(const char *name, bool slot_found; int ret; + if (!kdev) + return ERR_PTR(-EPROBE_DEFER); + if (!kdev->dev) return ERR_PTR(-ENODEV);