From patchwork Fri Jul 28 07:39:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 9868065 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 26BF760382 for ; Fri, 28 Jul 2017 07:41:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A4172888F for ; Fri, 28 Jul 2017 07:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F1D928896; Fri, 28 Jul 2017 07:41:25 +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 7DC202888F for ; Fri, 28 Jul 2017 07:41:24 +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=2f7kPCTUhLjnfPuOFTSBfxNHIF/GOYh1JMiDLe80/a8=; b=Pz5zt43A3gxTcO pXrGFqEPZ+OQfrFhOXEjp8hzZOQHMkRTKEGvs5y7PaEI8ceMa3ansdYkTO0aE64jcj6A4ty9BqxIU Q9ozkrpyBIUrCu408JVyrLyY5WhgmcvUyCtP2CwGIzVv9a/q9tT8RXbMVxtm1XQvwce44ZppGkSBM MNL2ICyHg59xdQVZXOI2eUolq9iOTp0AWeYVWrZpilRjXf7SmLR2y5QVWtoA5JFv2kGX3/fQ8Ytx4 aiw4ReaYqsAo2j9RwIyYnouElislUd6eiBUYy+i+U1EFl4TgqQKkgWQZ25lRLswU4fT8ZUkz1IdJx qKCRMjBTtAyU+goQWSMg==; 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 1daztg-00074a-O9; Fri, 28 Jul 2017 07:41:20 +0000 Received: from lelnx193.ext.ti.com ([198.47.27.77]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1daztb-0006pZ-NL for linux-arm-kernel@lists.infradead.org; Fri, 28 Jul 2017 07:41:18 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v6S7eqGJ010086; Fri, 28 Jul 2017 02:40:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1501227652; bh=FwNvL0TVR8neUDpjPDQRVEKDOTQKp0VCLnRuZ4NGmP8=; h=From:To:CC:Subject:Date; b=mU2mLV/HcLo8ycLPnwfMV2f5lJEoqSWTX7/01xrb48+upqZlQm8CBdEtyklbyfNBY fUJO5nx2hAG2uz5ouZSCi/Nm8uwNTHyqHTkh8Y81jjYVOdMBubT8LQOnzGjJNR4Ai9 BJliCp+1wmK2MnVj/nCyY7OlxRc4DT0v6wqeLlgo= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6S7eqhW016850; Fri, 28 Jul 2017 02:40:52 -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; Fri, 28 Jul 2017 02:40:51 -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 v6S7enxj004657; Fri, 28 Jul 2017 02:40:50 -0500 From: Keerthy To: , Subject: [PATCH] soc: ti: knav: Add a NULL pointer check for kdev in knav_pool_create Date: Fri, 28 Jul 2017 13:09:16 +0530 Message-ID: <1501227556-21087-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-20170728_004116_016326_C219CDDA X-CRM114-Status: UNSURE ( 6.49 ) 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 --- 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 -EPROBE_DEFER; + if (!kdev->dev) return ERR_PTR(-ENODEV);