Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2175854iof; Tue, 7 Jun 2022 22:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfadwhP1eK3L2zJ2vOy8BQqLoCCWFLQcb4gUgJQqfocr5wZsyI9h8754UJ7crkAql66Krq X-Received: by 2002:a17:90b:4c4a:b0:1e3:3b3:8800 with SMTP id np10-20020a17090b4c4a00b001e303b38800mr36261726pjb.6.1654665248165; Tue, 07 Jun 2022 22:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665248; cv=none; d=google.com; s=arc-20160816; b=o9jU4QxvP7pJNQy/G4gO3E/FW/xRVKqC5UxmHYpnoBbCoUK3Ng07WxDH+OiryYG0/E lSyMohR60kdgTnN8MsDoMrur9A/Pq5i6uN9n/jmnJSqw6XJnyRyzIvg8hCO1N9VMcxeW vHRLbvRA2zW4Qjc1FP38NTechiqKD2NJtyT7aVEJ8kxn8rbN9djkc0iOr2BJQcPhmXjw AVdAy9vKkPh0dIwvVkxkPLdWPmcaaGxU3jy8bu1pilWWnxdTPslSCj9adzWtvkcT/2/I MdzUlIOmNftIwbiZqhFpsjeQim/9UI4lMqEjFTFRytfaT/gIRzONHf7/uxcJBNmtC8Tt QVVw== 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=rpstBId8ExNmIc10n+fR62yEIY94EvCdZaddk/DPxZ0=; b=d4KxAMQ5+7lwG7hmQfg1RAVXYlz95yPHqqONEN2rpZMlPUSvrMzdj2+QhyyG0l+6QF 2XNNz4PFdwS+lQOoT/fQ3Xm3nQ+vGMq80tvcyAQtO0WkB74DJGDWBP+lPkRbkczKd2LD uTTEEWpaGmsiWDVwYn1Ze7uj8eXTjE3B48Tq7dUzk/IwoXfD1cpgT7cxEgGTfCee9DFP MrELCfRgLX1ulClNryirXX/SgUPZRSm/Z+52F86BYsCB2KSSkGNWLXXt4JCtDkPb4yI0 nmMa6XiAjSeP/reWUIs6ZG5k8jsILmGUooG8bdtacvFgg9L09Q4eH0PR99Q/jpE0Zzuw lh1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jIBh0/iN"; 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 ik14-20020a170902ab0e00b0015830f35108si24274716plb.209.2022.06.07.22.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:14:08 -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="jIBh0/iN"; 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 711F7415891; Tue, 7 Jun 2022 21:44:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245131AbiFGRw5 (ORCPT + 99 others); Tue, 7 Jun 2022 13:52:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347803AbiFGRfs (ORCPT ); Tue, 7 Jun 2022 13:35:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8A6106A43; Tue, 7 Jun 2022 10:31:28 -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 ams.source.kernel.org (Postfix) with ESMTPS id 65D4BB822B7; Tue, 7 Jun 2022 17:31:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB77FC385A5; Tue, 7 Jun 2022 17:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623086; bh=uq/JekMtaPZ0oAHRiPHyKQrtVt39E49VpuMaXECQb5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jIBh0/iNM8JnxL7+ep4OPwOn1NULisB/SXd7xFeF+apDsI2zSDbEp7fJODP4XKT4h R6JL6wsSQ4ffKtSaaTE5nWLMK8srMrDdyk45dmr29Fj/K3AfWDtwkSf1saqnO2yNh2 gUqb3R8VAeJ+LEp30HqtAbWJ7u20N7x7YFgjhvu8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongzhi Liu , Haiyang Zhang , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 249/452] hv_netvsc: Fix potential dereference of NULL pointer Date: Tue, 7 Jun 2022 19:01:46 +0200 Message-Id: <20220607164915.979358110@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 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: Yongzhi Liu [ Upstream commit eb4c0788964730d12e8dd520bd8f5217ca48321c ] The return value of netvsc_devinfo_get() needs to be checked to avoid use of NULL pointer in case of an allocation failure. Fixes: 0efeea5fb153 ("hv_netvsc: Add the support of hibernation") Signed-off-by: Yongzhi Liu Reviewed-by: Haiyang Zhang Link: https://lore.kernel.org/r/1652962188-129281-1-git-send-email-lyz_cs@pku.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index e3676386d0ee..18484370da0d 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2629,7 +2629,10 @@ static int netvsc_suspend(struct hv_device *dev) /* Save the current config info */ ndev_ctx->saved_netvsc_dev_info = netvsc_devinfo_get(nvdev); - + if (!ndev_ctx->saved_netvsc_dev_info) { + ret = -ENOMEM; + goto out; + } ret = netvsc_detach(net, nvdev); out: rtnl_unlock(); -- 2.35.1