Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6886752ybe; Wed, 18 Sep 2019 10:38:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmyCNWBM8vQtI4SWNMap5qmi6U0oz+BJkApTsLg+W2Zt9pevixr6c6JH9bEVvTgjdc//2z X-Received: by 2002:a17:906:3087:: with SMTP id 7mr10686630ejv.212.1568828282949; Wed, 18 Sep 2019 10:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568828282; cv=none; d=google.com; s=arc-20160816; b=lOID5QCgGS2rarvqbuBGn89VhEQA4vAZeJWgNsvXsQTqZ5ur+APhmYt7CBESp+hjel 1BihQ2cDRA6JYQEtNgUOHSH4fsexgmm8N7ydfWRWsJdSUQqPu6UQa0cSr6udGteQBx9G mFoGWNP1C/U0BjRk0+gPJx50BGF8v0HQoB3tynLH10bqjbCDnERdcVKGGdBtF/M3qUQD 9756tjvPArN3BnubbP7KGmNzv1/J2B2r1wO9fdqxng+xeVY9NLjyNU3q4ZrTOhE0JvfA Z8ZbOMjb3ucWWEsHcJ7pObGCIyXD4gqld4aS5d0aTdf/+5SZI+CYyQqNEDELU1PMgIxT 9Bqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=NjiZCOg5xFo4Z5niVDbJDHIcUX3lm7EmZSt0FVk2UN4=; b=0QCVDCgrH3fbvyE4W60pbmNSvpIaYzaGWhYdOnzvN/UtQ09YWHksofhUWoMdvxEO7i hWPZCS1DKHlB5oCWr+H0Ov144s3OpumDOfE3q8DNf5IONt2B4ZBEVcrlSIkRjY7UChn3 aZoN3/8uceY09+byOnjIKCCh4jLMOMqeyr+Gi/dIoXKXbLz7SWLU5iRKy66DNpbVidVi NwCNKZvNewTWe3983DKly5x/pnl6A4QV5Uy45LLeYZIRv7qvbxRUNgPixy2WGSb3VdyE h3MgvYXGRi/F0l4Px3CFwSkupHFChkxWObk5+npepjMZVeIT48GZllo38uvN1M01aCw1 nEhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=TLSqxsCQ; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d58si3818287eda.62.2019.09.18.10.37.38; Wed, 18 Sep 2019 10:38:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=TLSqxsCQ; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732007AbfIRQfa (ORCPT + 99 others); Wed, 18 Sep 2019 12:35:30 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57564 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728713AbfIRQfa (ORCPT ); Wed, 18 Sep 2019 12:35:30 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8IGNYVA178534; Wed, 18 Sep 2019 16:35:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2019-08-05; bh=NjiZCOg5xFo4Z5niVDbJDHIcUX3lm7EmZSt0FVk2UN4=; b=TLSqxsCQV4cK9e8hGbsLr0Nt1u+CPKN0Murs67RcrbtobtmvuF7K/rAkUW0YlFILD+91 OJbBQlQKJ4eNb2gT7wKVr9qpkXqob/XEG0V2eWbwEssn81r2Epjyn8W7F7EmggwO/UlA 87Q+h4eDFV8/3Cax0pphixSF99s0gQQm6pAKZ3GKBysFj8n9SOu9zpNSMxLN/8bKdKWv OQbJi8EbiS2cm/Ky6WZIlNhB9D6nG3HJBEvY/ESz5xH65iqFSE9+lvL54adC/fJasIPF ecJ2/jdg3M1UZGDeQD/dSO6QaFueYj2NbZHHatHvlqSkm97kfmcQroZa0MVXN4Hb6DuG uA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2v385e54nt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Sep 2019 16:35:22 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8IGNLQr048332; Wed, 18 Sep 2019 16:35:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2v37masp0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Sep 2019 16:35:21 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8IGZK6D012500; Wed, 18 Sep 2019 16:35:20 GMT Received: from x250.idc.oracle.com (/10.191.241.104) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Sep 2019 09:35:14 -0700 From: Allen Pais To: netdev@vger.kernel.org Cc: davem@davemloft.net, kvalo@codeaurora.org, libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] libertas: fix a potential NULL pointer dereference Date: Wed, 18 Sep 2019 22:05:00 +0530 Message-Id: <1568824500-4243-1-git-send-email-allen.pais@oracle.com> X-Mailer: git-send-email 1.9.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9384 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909180156 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9384 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909180156 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org alloc_workqueue is not checked for errors and as a result, a potential NULL dereference could occur. Signed-off-by: Allen Pais --- drivers/net/wireless/marvell/libertas/if_sdio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c b/drivers/net/wireless/marvell/libertas/if_sdio.c index 242d884..30f1025 100644 --- a/drivers/net/wireless/marvell/libertas/if_sdio.c +++ b/drivers/net/wireless/marvell/libertas/if_sdio.c @@ -1179,6 +1179,10 @@ static int if_sdio_probe(struct sdio_func *func, spin_lock_init(&card->lock); card->workqueue = alloc_workqueue("libertas_sdio", WQ_MEM_RECLAIM, 0); + if (unlikely(!card->workqueue)) { + ret = -ENOMEM; + goto err_queue; + } INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker); init_waitqueue_head(&card->pwron_waitq); @@ -1230,6 +1234,7 @@ static int if_sdio_probe(struct sdio_func *func, lbs_remove_card(priv); free: destroy_workqueue(card->workqueue); +err_queue: while (card->packets) { packet = card->packets; card->packets = card->packets->next; -- 1.9.1