From patchwork Fri Mar 15 06:20:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10855805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD1C96C2 for ; Sat, 16 Mar 2019 09:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A6202A589 for ; Sat, 16 Mar 2019 09:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B5C72AA89; Sat, 16 Mar 2019 09:38:16 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC5AA2A589 for ; Sat, 16 Mar 2019 09:38:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 188B4920; Sat, 16 Mar 2019 10:37:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 188B4920 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552729094; bh=+ah6c/6qHmeRqPY+koKWh93zWz7yrq28AiVQo+hLl+Q=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=m1aLmXP/dG2cYtTRjOhKoeNuriVTr+4z7cguNH30TnLbiuR7Oiawzs+UL0Oz37VIf U3MrcxIoyOY6FdupFPIDSgPQELs3mEm9REhr/gFyQ+Ut37lcSxMvYRhfXQZvM9ZAIO sBkEhWPm+R/93VYIM68eRJ/fv0F3JT+VmvtQ+Ams= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C4E89F89727; Sat, 16 Mar 2019 10:33:56 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 019EDF89701; Fri, 15 Mar 2019 07:21:03 +0100 (CET) Received: from mta-p6.oit.umn.edu (mta-p6.oit.umn.edu [134.84.196.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EA5E7F89673 for ; Fri, 15 Mar 2019 07:20:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EA5E7F89673 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=umn.edu header.i=@umn.edu header.b="EJvR+z+H" Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 19BC5D47 for ; Fri, 15 Mar 2019 06:20:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b0TbwTlk08LN for ; Fri, 15 Mar 2019 01:20:56 -0500 (CDT) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id E88A4D16 for ; Fri, 15 Mar 2019 01:20:56 -0500 (CDT) Received: by mail-it1-f199.google.com with SMTP id y6so4298777itj.5 for ; Thu, 14 Mar 2019 23:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=Br3/U0mf/R/jQwiIltWwAExumrY4nZjRkWM2M0apZa8=; b=EJvR+z+HXKYN9bnEr7CKAv9UkVhR3jM67CJYW7G/gklZEDYExMUrvVSqw4kxOaOiGb PyvPuMQWbfTsqn9iDAYgckLtuX2Q2lpcsxTsX7gaXd/CvB7N8DGeQIobAhqd5v6NaZ2e FYYQkvkl8/d+U6D+8wySPfKk6No0gH7ThZT+cHy2topxZkKkTwQpliir9kJmfT8IFjhN DoW3+daElxaJtCbGsX3B6k1inJRZ8eTHM/UP9PtG4Lzxsl2TCTxlLh/Se9k/0F24PeLX fzXvMP0rDgADOqt6ynI8zxq9CbS5k/BnpSn0ENTcC7b5mm762lCWe0pkLZmSQ7/0khfj PnAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Br3/U0mf/R/jQwiIltWwAExumrY4nZjRkWM2M0apZa8=; b=to3tl+FfIcelRy9EKXlp64jK/SBPVegJU7/8X5y9MJWAEq0Y8zXJBnKaoP5hF6VM0g Lqncm+9uDOmISW6G/eCfT446M3+O3uzgt73wTTvOGTaK5x8MtlW8GafUMGV+h3WpcdLx wXV02EcvkBN4phxIA+QUftLXHsSNVDpTop963UTs7t6sCsdDGbJjcBEllJHWpNxIvFSt ScwIGl0naNx0WQ3uWsNIsTbP5nDam0W29XhXtagvH2mp7M1HMqSR2jJJrdx7dj9s91A9 u62X0Us7YiGUWkAT4WuyP/XOypH6zOzvwsNxtqNrkGSKN7qMGGQCD5U1meV/ixBFJYY1 GwTg== X-Gm-Message-State: APjAAAVUQzWchY6vhLCiR88HUHH/zD9C257MN3JCGZHY2EUigVq3yFqn rqM4HsO8u5YmjU7yB5M8O1GtbZmcFEgPmcoT79MJafDeIXsVFpBzBrHxcB8lUDKj8xtxpxGCmwV YKy8qVtCMi+q/yvvGnry6uL9Y49Q= X-Received: by 2002:a02:8a4a:: with SMTP id e10mr1457821jal.120.1552630854881; Thu, 14 Mar 2019 23:20:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5AbrXvR3MYaIsOrtbaEE3epm5jjU38uitbYmdpb9Bs0Ds2f/TKZMmNYU1UQbz2VJyPns+Tg== X-Received: by 2002:a02:8a4a:: with SMTP id e10mr1457803jal.120.1552630854477; Thu, 14 Mar 2019 23:20:54 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id u13sm495570iog.80.2019.03.14.23.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 23:20:53 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Date: Fri, 15 Mar 2019 01:20:48 -0500 Message-Id: <20190315062048.16642-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Sat, 16 Mar 2019 10:33:48 +0100 Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, David Brown , Srinivas Kandagatla , pakki001@umn.edu, Andy Gross Subject: [alsa-devel] [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP In case platform_device_alloc fails, the fix returns an error code to avoid the NULL pointer dereference. Signed-off-by: Kangjie Lu --- drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 71f094c9ec68..f3585777324c 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1342,6 +1342,10 @@ static int of_qcom_slim_ngd_register(struct device *parent, return -ENOMEM; ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id); + if (!ngd->pdev) { + kfree(ngd); + return -ENOMEM; + } ngd->id = id; ngd->pdev->dev.parent = parent; ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME;