Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2190421iof; Tue, 7 Jun 2022 22:40:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx53I8+ruw3hDjOHjSlFpO+fy0I2qMtrl78Fxjk/jVf8+zroi22izqEZD9ASSH7qKGnX9F7 X-Received: by 2002:a17:902:ccc4:b0:156:5d37:b42f with SMTP id z4-20020a170902ccc400b001565d37b42fmr32809465ple.157.1654666848363; Tue, 07 Jun 2022 22:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666848; cv=none; d=google.com; s=arc-20160816; b=xekuYW78kl9pYXyG62nrHZ3P2NEY+XfKKtpBdAe/mS1u58wg3pzK6rXO8xUS9EtuBg TV32QlDnw0ZAFLoVaZVizPIfiOnouG5UNPRAmXPxW7V++KlX3ZwRdyBhQmsxwV3F2R5f IuGwOy2iX3Wgwhw303xK2nyotPk8rVOEer7MrYWFiPIQPv13NaX/F6fLTyyB6/NWFKKd NZekiEW07ggmooxGX2TzSSOrOkdRCv6MP5LNAPFcQ3bYMOfDp6oE+xBA9EmUgAnAkzpg gxf2FRNGOuZ0iUUb9lOP+QVW5aK25fP3FbRbToHOTDLnbctRWE6FlpkbAoUVerl4blU0 5MDw== 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=HWxdQfrY+CEAuY46OhMbt+8p9u7w2g64rvjL3hU93Nk=; b=L5gsTWJPwg3MVdOwdh3fj4AB/RONoF9pxtgfbC5Ya2nziNeOQFs1dpadwtV++q/HnZ dWhSldArL/4uIYBFNC1VfQ9PNg18gyGWQTW5ZmQKhsnSISIPB8JMPrWqSBu/Xenjidol WaBsmPB/noC+Q0VGRo809/SGaU1C4EXIY3bG1exXPI7R1wLEYYHGu+9oxv7ca+DHyMVD TDMMuzHtBsPGRXjGoY+3qjVYnemdwkzgLOIL4fBH8jDHJzWQ9ve60Gs7+EojOGW7gaeu Z8nSI/QQfb18AVO7hFpxzxXX/h4wBbAt7WEyjjqlid+eg3hokHnLgRhB7k/sDGEsjlEF mVYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RCQf9XRm; 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 v8-20020a056a00148800b0051c6152700asi2089495pfu.136.2022.06.07.22.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:40:48 -0700 (PDT) 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=RCQf9XRm; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 493463C619D; Tue, 7 Jun 2022 22:12:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378516AbiFHA3G (ORCPT + 99 others); Tue, 7 Jun 2022 20:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382609AbiFGVvi (ORCPT ); Tue, 7 Jun 2022 17:51:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C762923D571; Tue, 7 Jun 2022 12:09:05 -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 0BC4DB82182; Tue, 7 Jun 2022 19:09:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 607F0C385A2; Tue, 7 Jun 2022 19:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628942; bh=kHhAYoGsPhV9+EArSetHwxqqBlxp/Pw5NoliB/+7KMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCQf9XRmaouDwOPsyKZjKykbPNd1TuNbJQzd6ORUe0tkcVoPOkA2pEvLgAqHHS+ZT yGlY6PQdoFZ0vTqtFB3v5Nxc+811ioYmxfUDBbS0W0wjsb5u/dKlKT7oTZTDbovQEz Fc8+cWxMlWTx7GCrXcmKpQmqBdEBF9cwVb/k1t6A= 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.18 513/879] hv_netvsc: Fix potential dereference of NULL pointer Date: Tue, 7 Jun 2022 19:00:31 +0200 Message-Id: <20220607165017.766421564@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 fde1c492ca02..b1dece6b9698 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2671,7 +2671,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