From patchwork Mon Mar 11 07:25:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10846841 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 543A514DE for ; Mon, 11 Mar 2019 07:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3155C28E43 for ; Mon, 11 Mar 2019 07:33:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24EA928E62; Mon, 11 Mar 2019 07:33:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 AA79E28E43 for ; Mon, 11 Mar 2019 07:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbfCKHdU (ORCPT ); Mon, 11 Mar 2019 03:33:20 -0400 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:47300 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbfCKHdT (ORCPT ); Mon, 11 Mar 2019 03:33:19 -0400 X-Greylist: delayed 474 seconds by postgrey-1.27 at vger.kernel.org; Mon, 11 Mar 2019 03:33:18 EDT Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id C63F1AEE for ; Mon, 11 Mar 2019 07:25:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S_7ObY7_ssdG for ; Mon, 11 Mar 2019 02:25:23 -0500 (CDT) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 98739AEF for ; Mon, 11 Mar 2019 02:25:23 -0500 (CDT) Received: by mail-io1-f70.google.com with SMTP id b14so3525412ioh.1 for ; Mon, 11 Mar 2019 00:25:23 -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=V1yPZ5O5Ka3zAp6GBcGsu4rU8aLAHLAkjYh3VEHgCbs=; b=AnUX+TxrvZIpbmJystXg/7g9iKPf1o1eD6pSveUv0jET/6br/ikNcDsfWxCelhpGbx /SOrVrxbFkDWPxmTqFSoCqsSOc6W7o9icLfX1lZ/q4I4gBIUCK1wPrMYJaKC4kjpzuwR 2bxG127+R2ZHCVdeiBPMQD5hfV7AVNpU62WfJjWQLumJdWtnbJ2OmGDvv0BDujsELRFs HRWwc6iqTdSqfiIXZJEZU5sBggJU3KniQlgOxaXEP2gqWHhHbHIuKfx5THV/VzPkp3iG YV5VxGF7vIAyly3VkEC/Bl6CCjvNiGWWzuCHCqnXcb16BqjTGI2brUn+vnW4JP+npTRw LoNQ== 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=V1yPZ5O5Ka3zAp6GBcGsu4rU8aLAHLAkjYh3VEHgCbs=; b=aYzhQ2F/AhP1mD4Pt1hIxK4f9wrWB8ayi8nCBLwJjeR2LkvCUGLhpwv9Dz3apuSqeB XBuYW0wO3T66M9t+pxOwFtgAJLDCYhi9Y47MlvVAh4HV8m94HvPYCV4vlJI4UUnmPFYW 2Y51x9UidO3LD7qzyvKJ2sMI+yhakoVvAwoBtIYx0EQ/nUPL98N6SrLMnpaGbjL7rkBr UWorp0xt2qrgkzdkW/zTLgnHjyYU7VRXbji49nLjwA905BxkKpm/qtNB6ppqOE37xML6 0UdcifxYEq0/f1o0U3YYpOCQKt2SHKss79F/beT/FStzpWdl377vJBf6Ku5DGbUmlC5W IdQA== X-Gm-Message-State: APjAAAVU7Wmf/evOKAQuGADAajUN3KB46mFf5Upay1vIxGgIYfOlIy5C Dj89tWpo2G8W7vVBCZIshCdTrb7XYTN0RTiuADwTS5KcjYilcBXM/FOuLypDcXzg3w5NCtCDN6C jRQkVMz7VGrPg2aHENq/U5k8uDA== X-Received: by 2002:a24:45e3:: with SMTP id c96mr14086757itd.89.1552289123186; Mon, 11 Mar 2019 00:25:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYxB4ZFgw+YmFqKXxGAK0Yt4KlsntDtu3GzJlOJw5ThV/JA4EC4mK1YOQexw2btEyOfLqGFA== X-Received: by 2002:a24:45e3:: with SMTP id c96mr14086752itd.89.1552289122934; Mon, 11 Mar 2019 00:25:22 -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 y26sm1966486iob.16.2019.03.11.00.25.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 00:25:22 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Michael Hennerich , Alexander Aring , Stefan Schmidt , "David S. Miller" , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: ieee802154: fix a potential NULL pointer dereference Date: Mon, 11 Mar 2019 02:25:17 -0500 Message-Id: <20190311072517.29740-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case alloc_ordered_workqueue fails, the fix releases sources and returns -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu --- drivers/net/ieee802154/adf7242.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c index cd1d8faccca5..cd6b95e673a5 100644 --- a/drivers/net/ieee802154/adf7242.c +++ b/drivers/net/ieee802154/adf7242.c @@ -1268,6 +1268,10 @@ static int adf7242_probe(struct spi_device *spi) INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work); lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev), WQ_MEM_RECLAIM); + if (unlikely(!lp->wqueue)) { + ret = -ENOMEM; + goto err_hw_init; + } ret = adf7242_hw_init(lp); if (ret)