Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3111477pxm; Mon, 28 Feb 2022 12:14:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzo3dUrerJVMXZy+M1/wR3vapRgXKus+uzsEjKJBXYlYUoplPS8hs0pKVTJOfElDeAdm/do X-Received: by 2002:a63:4845:0:b0:378:43b1:a3b9 with SMTP id x5-20020a634845000000b0037843b1a3b9mr13488100pgk.221.1646079281144; Mon, 28 Feb 2022 12:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079281; cv=none; d=google.com; s=arc-20160816; b=c3MaxvHB39doHeedQ2WbHRFug5HmD5gGjBX2Q2nNmTX4kO5ZGRm542h8JkZ9yWfQPn YwrIB6lmk7AfyHQzCqwI5JXJtpEwkcS8knnA+I5n8cbavY9oQ376z2RN45gJvObP6KrP jgvnjhSpTxjIFFpHDUcZbzJ/ttJUvPt04LBfhm6vT49M2hBW1mWV4uwlN9Wo+LQ6neuj BS2/IS+b+ykCAI6psnLOMbf2zbPMumRmpH+64097Oad2X0gUHBIZuFDlnmAwzJ+C+lO6 zlSFws1HgvjRfWf4SFfp4pbAPXGZ/d1khm7wtgLkOuYfPQYW7Hr/DgfTGvUVBJFcFhAc zudA== 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=iqWatJ/iBQOGBOgmktbKM/DoJHWNXPMa68FqQ2HZtcA=; b=pDALZK4yneCZYMKqoxDvqUXt81qhP0QYI+ETEZxg2RzPhLfviEPYnv9MA+tkY/piR6 W5g7SDgqpi5WqqRLfiNDGM6mcmFRDfAXbuFTegzGwZ1yxQiy0TDHbD2eFkconEG/qB74 I1lq5Lu4izf1oUqjl/1a5DskAW8lPoWHbRnLugZOWILptXmzfixzE/JrXi8dszChwKaE JJeIIoFMYP8Z+W4e4JQSZw7xg4SB1Mo3s4ZoztSRRlV6IonjPOAaWp3BeWQ6XtEnX0/O Kp6sgGAGRJ/vThDe/BAY1Q8NJaoLdumaQVaqrO6ZspHntj/b76cUgRDxB6skuvD87JQa DI0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6vgdM10; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id t16-20020a63b250000000b00364c393ba3csi9920039pgo.211.2022.02.28.12.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:14:41 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6vgdM10; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 E12F1166A4F; Mon, 28 Feb 2022 11:36:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238271AbiB1RhP (ORCPT + 99 others); Mon, 28 Feb 2022 12:37:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238838AbiB1Rdz (ORCPT ); Mon, 28 Feb 2022 12:33:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A6877AAE; Mon, 28 Feb 2022 09:30:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 43A1C61359; Mon, 28 Feb 2022 17:30:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 538A4C340E7; Mon, 28 Feb 2022 17:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069448; bh=YKvPEg0zzOIBH0zwPdQEyNkdhgSjYM/EH+4eaRDEvs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v6vgdM10tLlQrJ1JDLC4lo0j953pQpoAXg13eGOzTCAsiklm2xE9AA6ktcPMFS2Xe NRSWPMFkWWpNmWSBs8SW+yVQVpksGlQ2S5BFMFpHHMgVZhtwZW652kgIXMrOWqiB6D myXn5nfqo7FoUQagUQJb9i6aOXKoHMxF/McXOP4E= 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.4 23/53] net: ll_temac: check the return value of devm_kmalloc() Date: Mon, 28 Feb 2022 18:24:21 +0100 Message-Id: <20220228172249.990160395@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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.4 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=unavailable 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: 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 @@ -1345,6 +1345,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); }