Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2632011pxj; Mon, 14 Jun 2021 03:33:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMgCXU4aEvUqsX3uvKNH2SRJmm1LN95CqdVR1KAR6C8Z6zDldOcj+btJmcMBm49t8qXk6o X-Received: by 2002:aa7:c9c4:: with SMTP id i4mr16508638edt.299.1623666806659; Mon, 14 Jun 2021 03:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623666806; cv=none; d=google.com; s=arc-20160816; b=qPjm8Z+GS26rYotm905BV2rmIzgOHurteefQ5nmaizXUeir1TWoihpAN96XlRF+SwK J9mK8HDtAk1QHKckNnCbY2I64hD+mafU8XcshyhJUnb0c8G0LQlry2IkynWbASJlVVu7 VBrF/ukoiCV0jrCdEMkqnR3hzygflnjOuOA6RM6Z9FzRAobUxugZqbhJJht28zUOwlqf WOd5ihCRrgH33WMSTL4cuR2ACh9Lf2RK0KR3Xo3aZkkmAPP1oDTw1UAjxFxaLNB+f4vc CkF48ZtWhkon3ipSuUPQhTQ0ENSCsWo/WmSAgJBC/nK+s+j98p+sxMDBbihRk3M39dFJ MR2w== 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=rHmbKi/b0IoIfgfIakjei7o/D7v5jHfY+wMNWI6jmVs=; b=it+tYarGbpnpQ89Q9FNHdJFoIRjbz7cBgC03oGpkxYbBusAnR8/HOqkX93wQBRJGad Qm68ENLh+zQDuZdMGb/sqCR22ogSplU+oF36bfWqzBL/Cd3Yef4vaIAZ1AIFBXBNT9CY TSLQcSJsCqhtB9TRH2wArfkHyrl0kyI1HERGl+YUb0XQhUIBXFw4R0oM76pTJHgt+R2l NK5sh2GbivNCi4gcz+443VMR1I/Rnj5H2Z+XGMUTN8b6syhIgNTyg0vPKUk8FyOZmMyM HPDD1h2ZgmlHvDhR2ofnP63CzZlFIHUcZKRERVfLfm/bwNcT8FyVOXtcgY5/+0bugLvs LOgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y8sAUZG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si11177510edt.5.2021.06.14.03.33.03; Mon, 14 Jun 2021 03:33:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y8sAUZG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232969AbhFNKcz (ORCPT + 99 others); Mon, 14 Jun 2021 06:32:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:38298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232966AbhFNKbv (ORCPT ); Mon, 14 Jun 2021 06:31:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38D85611EE; Mon, 14 Jun 2021 10:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666575; bh=JdWShn25uGNjts7Gh0cwlIcfkNhO76pSuhDxgBRD6mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8sAUZG4jrg24tI3o6IMKaDjuVZUg3sAipPMHp+VCk8Y9QuhV/JSof8hNKu1I3Pn3 8VRekrHpb1sdlr0+XEWgFajWwG6uH2JDbJqnw+mYr8+2+9Rh9zNM0a8acUWJdGqj3q hbBigdu1oar9FBNSpoUxLR/rcPR4qlZW4rNePKaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Trond Myklebust , Sasha Levin Subject: [PATCH 4.4 29/34] NFS: Fix a potential NULL dereference in nfs_get_client() Date: Mon, 14 Jun 2021 12:27:20 +0200 Message-Id: <20210614102642.515540737@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102641.582612289@linuxfoundation.org> References: <20210614102641.582612289@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: Dan Carpenter [ Upstream commit 09226e8303beeec10f2ff844d2e46d1371dc58e0 ] None of the callers are expecting NULL returns from nfs_get_client() so this code will lead to an Oops. It's better to return an error pointer. I expect that this is dead code so hopefully no one is affected. Fixes: 31434f496abb ("nfs: check hostname in nfs_get_client") Signed-off-by: Dan Carpenter Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index d6d5d2a48e83..ba2cd0bd3894 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -377,7 +377,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init, if (cl_init->hostname == NULL) { WARN_ON(1); - return NULL; + return ERR_PTR(-EINVAL); } dprintk("--> nfs_get_client(%s,v%u)\n", -- 2.30.2