From patchwork Wed Sep 26 10:42:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10615711 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 DCCE515A6 for ; Wed, 26 Sep 2018 10:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAB072A647 for ; Wed, 26 Sep 2018 10:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6C42A650; Wed, 26 Sep 2018 10:44: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,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 27C1B2A647 for ; Wed, 26 Sep 2018 10:44:13 +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:Subject:To:From :Date: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=Atrc2GwJ2CPnBKEyJENsGR8/pRcSl5/16j3QD3NUUs0=; b=GlNIe+eLr8Lm+D qhN+C4v7DojeL+L77RXfsQ+3o3nxRz07i5olbT6wwidms905VAOm7sK1BJWxaNOBW0nQZKEHIv7C8 L6OdtLDemkLg1Sr0FcDp3wm6CasxsUNS2ggi+VuepjE0atlHT+qjwXcSTRmaDG8VkejbBvWoYYE9v 8qLolALZxq1cK69IbVYSedbvGuzjl7QhTmdJYX+krmSM8i4BKcPr7/DijRDWnuKmnSzTbs7P+TIJO 8IZnXC1D7cjlxbtpfn3oEGISb7ocx4nkdwAzezXxyGYdKbqQ7FChGEh03269ul56s6748nlCDm+GU mrjtsHiXARsD8bCzI3UQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g57Ih-0003HZ-C5; Wed, 26 Sep 2018 10:44:11 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g57Hi-00036M-L9 for linux-mediatek@bombadil.infradead.org; Wed, 26 Sep 2018 10:43:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0rlQPQ1fyal5i6/j5fBscU7QZ68/Bcn47NkPLLkzv8U=; b=CFLGM+HeKf5Hn8jdV2szIRReU/ qSUjGXism9qims3RbanuzefFkmN32OMkAFm1K5cfIoKRqIE1pgM2G4zFTBJtiEeEZytW3oAeiyMB4 6Vt+iqXz4K6VVRjxcVslbqE391ogDbme/EVvWVwAorjpzIwdekFsEm4W2bUG6mCBd2dD+S8Sb72Qt gX4l0bzEf8PZxAGjQ1I7gEJ3Daqv0VQNALOktW/QcFe7D5mIuTVjtmvJkp10ULjiZQ3UcJsdrops6 IfBlgEqJGUCAKXLB8qkllkNJz4GVxLz6uWoggd72ytYtdxCE6VpLBuJN2pwkPjVy8Vv6aTX+zFkMT m8mLhj1Q==; Received: from aserp2120.oracle.com ([141.146.126.78]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g57Hg-0007Cd-2o for linux-mediatek@lists.infradead.org; Wed, 26 Sep 2018 10:43:08 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8QASQCf091223; Wed, 26 Sep 2018 10:42:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=0rlQPQ1fyal5i6/j5fBscU7QZ68/Bcn47NkPLLkzv8U=; b=ViXv5LSSJKzZf7MMAMKyLKj7gpTcz6d7ZHGlDX31gN+16M8jZNBd83f8CEINqVnSGLJy L9At1QLFBQa2tyNqJobSdYMXmXzBKo56SOF/GNDVfx8BitmmEFEAqywMedXHKoD+tSwl 6saUyX8eAAzCHymtCIqqbxTJ7KyGPCrT+4kdLaCHUo8ngGIxgRwzQ3VrMDP0sFg92b0o ISNb2gSj9npVAUTYBr4OUHYd4fwvai6C7UPZN4kFCiIAmRLy3OxQw+/v8WguMcsMdLyv WZYojdMScxniJbm/pFP2ggQwSoWn5JdmtB9WcEL5191tuecwg7IjbaYGpHKXa3IxOUSE OA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mndpphkbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Sep 2018 10:42:30 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8QAgU7h008385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Sep 2018 10:42:30 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8QAgTMd025298; Wed, 26 Sep 2018 10:42:29 GMT Received: from mwanda (/10.175.46.9) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Sep 2018 03:42:28 -0700 Date: Wed, 26 Sep 2018 13:42:30 +0300 From: Dan Carpenter To: Linus Walleij , Zhiyong Tao Subject: [PATCH] pinctrl: mediatek: fix some NULL checks in probe Message-ID: <20180926104230.GC14535@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9027 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=843 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809260105 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180926_064308_243752_864FDAAB X-CRM114-Status: GOOD ( 17.22 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Brugger , linux-gpio@vger.kernel.org, kernel-janitors@vger.kernel.org, Sean Wang , linux-mediatek@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The devm_kmalloc_array() function returns NULL on error, it doesn't return error pointers. Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings") Signed-off-by: Dan Carpenter diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index 4cf0fea30b7d..d2179028f134 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -836,8 +836,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev, hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names, sizeof(*hw->base), GFP_KERNEL); - if (IS_ERR(hw->base)) - return PTR_ERR(hw->base); + if (!hw->base) + return -ENOMEM; for (i = 0; i < hw->soc->nbase_names; i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, @@ -863,8 +863,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev, /* Copy from internal struct mtk_pin_desc to register to the core */ pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins), GFP_KERNEL); - if (IS_ERR(pins)) - return PTR_ERR(pins); + if (!pins) + return -ENOMEM; for (i = 0; i < hw->soc->npins; i++) { pins[i].number = hw->soc->pins[i].number; diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c index c27597cd3931..3bf5dd552749 100644 --- a/drivers/pinctrl/mediatek/pinctrl-moore.c +++ b/drivers/pinctrl/mediatek/pinctrl-moore.c @@ -608,8 +608,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev, hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names, sizeof(*hw->base), GFP_KERNEL); - if (IS_ERR(hw->base)) - return PTR_ERR(hw->base); + if (!hw->base) + return -ENOMEM; for (i = 0; i < hw->soc->nbase_names; i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, @@ -629,8 +629,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev, /* Copy from internal struct mtk_pin_desc to register to the core */ pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins), GFP_KERNEL); - if (IS_ERR(pins)) - return PTR_ERR(pins); + if (!pins) + return -ENOMEM; for (i = 0; i < hw->soc->npins; i++) { pins[i].number = hw->soc->pins[i].number;