From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFE5DC433EF for ; Mon, 28 Feb 2022 17:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233850AbiB1Rll (ORCPT ); Mon, 28 Feb 2022 12:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235379AbiB1RiZ (ORCPT ); Mon, 28 Feb 2022 12:38:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A8A8595E; Mon, 28 Feb 2022 09:33:50 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 2ED47B815B3; Mon, 28 Feb 2022 17:33:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80DF6C36AE7; Mon, 28 Feb 2022 17:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069627; bh=lQ+7k5oeZm6QWxae9IbuqKGb12GEJxBClUai0U7CMSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JuQz/aegm32fyo9g9NtMgafoxlwfmAv5WpOI0DqHRsCC9uwStZggswN3S75OPcga5 UauwcOv5gHZXqIQ9gb+dW7gV5iSpdPbAH9COhp+T4aywmUZtWeYUo0B6JYEFnUNRKe JKEFTzd68ySGQl/AYB+alkVvdxr1ma+SkdNdRNrM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoke Wang , "David S. Miller" Subject: [PATCH 5.10 35/80] net: ll_temac: check the return value of devm_kmalloc() Date: Mon, 28 Feb 2022 18:24:16 +0100 Message-Id: <20220228172315.690261354@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172311.789892158@linuxfoundation.org> References: <20220228172311.789892158@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoke Wang commit b352c3465bb808ab700d03f5bac2f7a6f37c5350 upstream. devm_kmalloc() returns a pointer to allocated memory on success, NULL on failure. While lp->indirect_lock is allocated by devm_kmalloc() without proper check. It is better to check the value of it to prevent potential wrong memory access. Fixes: f14f5c11f051 ("net: ll_temac: Support indirect_mutex share within TEMAC IP") Signed-off-by: Xiaoke Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -1421,6 +1421,8 @@ static int temac_probe(struct platform_d lp->indirect_lock = devm_kmalloc(&pdev->dev, sizeof(*lp->indirect_lock), GFP_KERNEL); + if (!lp->indirect_lock) + return -ENOMEM; spin_lock_init(lp->indirect_lock); }