Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp633357pxb; Tue, 5 Apr 2022 16:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8BCmJmXZ3fogFXnpKp3sniW0CrGU+Ma5vXrMTOvjXYoPJoeN1p4pEzLDQ6HfFnm+/DnVP X-Received: by 2002:a17:902:8c81:b0:156:7fee:643b with SMTP id t1-20020a1709028c8100b001567fee643bmr5808481plo.59.1649202069825; Tue, 05 Apr 2022 16:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202069; cv=none; d=google.com; s=arc-20160816; b=xi7D3Vw2/H3Q/qtrUqVCtjLpG5AHI5NJ3uwsb9A47kRHdGbd6RoMreRVVW15q/HaoK u3Z0OpPJJkzmNdNZDcKsQZqdNrRugxgDST0RlssAPdOn8cm6JMTJffqzcLqeluzoqlB/ ZEW8iRlU7PqKUPPbkNHwFzfJ6tpifVYSnSV+eYo7tCwjjQr/ezZqVAj8zRNTxiCMdjos 4UJCJ+MYlDSpKTU6eaveUNr2fYXXu0jD4LkLQf5TiFCYd8+Z3U67NRXoV1Smj3ZNIxqJ WHkBN4U0TRWtGKyTpVtyYURDtoO4vQPVJlvIM6aus/DwsHz4nFJwNu4mZalvjRZ7wcKb oAEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WHZBdo33icG4dfG2SxteQwmQhzEuyS04Anf2+dmdw3A=; b=mxeIWLt4DS35fu1Ek/KOVBy/dO4YyYCj9nSGKTvAMTZby3De2k8SRQPdbg23SnfPN6 WATe7wNWuWrFuTm6spWfxQdu+XzxH9LAZ6YEBWmQKzWnN5CM1taMerdd7W5O8hXqBgvn kL5Dfu4eqpE7kC8i90svYiWfs1g6882sULVsYV0TPgId9zrC6ehwL1kHu1J+mUDXbUuB V2j8l2LppufZHl+Y6BhKEIBqcKNqIPqyUe2xFe9k9IP8hMpWQtdpY1LGovRi+nWfZLYD oVryoYjOiC0w5b6wbS+ZlOW3IrJl+l+AEa+cmN3UaOuuTabED2qA8oO+lSsV3exFf9xM b7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q3ptPLm+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g37-20020a631125000000b003992ad63332si7503511pgl.404.2022.04.05.16.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q3ptPLm+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B3AF91D12F6; Tue, 5 Apr 2022 16:25:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237325AbiDENKb (ORCPT + 99 others); Tue, 5 Apr 2022 09:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344191AbiDEJSh (ORCPT ); Tue, 5 Apr 2022 05:18:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBBF29969B; Tue, 5 Apr 2022 02:05:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 69DB761564; Tue, 5 Apr 2022 09:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E7CCC385A0; Tue, 5 Apr 2022 09:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149513; bh=96OvkCivmFseK7bEObf6KFbVIP+u0ZzPNMVNOVGBOvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3ptPLm+P/wILC7gCxMgHsH/x9ufKSfnh+K4OtEQXQ8mxKsf8JU8SzJHbt3C7E0Ju 12FNuvcMRa4bTT0DYaN2s5xwNgeAncI0nfrE+8tba5UrYaGuzwBC3xxbpOLLX0Zwa3 8jyK4vunyKb1rdV5sHYqpNCh6sHWWw5ZKP+ynSQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheng Yongjun , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 0741/1017] net: sparx5: switchdev: fix possible NULL pointer dereference Date: Tue, 5 Apr 2022 09:27:34 +0200 Message-Id: <20220405070416.259188782@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheng Yongjun [ Upstream commit 0906f3a3df07835e37077d8971aac65347f2ed57 ] As the possible failure of the allocation, devm_kzalloc() may return NULL pointer. Therefore, it should be better to check the 'db' in order to prevent the dereference of NULL pointer. Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality") Signed-off-by: Zheng Yongjun Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c index 7436f62fa152..174ad95e746a 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c @@ -420,6 +420,8 @@ static int sparx5_fdma_tx_alloc(struct sparx5 *sparx5) db_hw->dataptr = phys; db_hw->status = 0; db = devm_kzalloc(sparx5->dev, sizeof(*db), GFP_KERNEL); + if (!db) + return -ENOMEM; db->cpu_addr = cpu_addr; list_add_tail(&db->list, &tx->db_list); } -- 2.34.1