Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9111416pxu; Mon, 28 Dec 2020 06:57:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcmDsiJxKkHsGyAbLkqSfjbpWcDxoVcfuHRTSqYj5QUBYc5ZwWkricY3btZT57ELvsZowP X-Received: by 2002:a05:6402:128d:: with SMTP id w13mr41810933edv.56.1609167422320; Mon, 28 Dec 2020 06:57:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167422; cv=none; d=google.com; s=arc-20160816; b=duHKGlgEjVTJJr8ph6h0NkjQQgBguW1D5ijZUF+B5tMcJhFMq6Xdn2gILBVenvAyHG A1nRdDaTtUTrakqiu113SmV4n4Bbzkgi9CV+ekbh+9LtD9qF+EMfoCzYJcfsm7WZUBuY 4I6hrhqHJqFVs45zQBBet8m5IHEKilSz6RF/i5AgOHXKqMHVDoOIir8vCkfX0/IW0oJx rivj4BUrBB465e9SH3ZNSXYGZgDUvLdeWmtOaJkXLvwAcEVlHqzKTWuY7E9DyT14shOK 131hobtT8slWGQngDYgGVGEag4RogBGFze83yJHxhhBamxsDlEYUSgccC7GQUj6HFTWd z4/g== 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=Q0DW3Rabm4gL2IYy/xEIE0JdwbgSFOtv7+3K4tx4BeQ=; b=iskCf7MMWtBJ2lPMvcmLPKoVMTUiEyFmGNCZOo5PNsVACW5lgVt1cVqRLDYcawyaKg RGNs+NtkwhonKlVyMGIoSTCbSLvr0JJyf1kUvo3tsEU4scU5yVk6n+/znrwVUS6O83sp fUr/gjl0fPP6SJQkwXRH1Mrv9iAA2oW/fLWd6by8NSw+zrsJXreXsgq4l8VfmJDDQMfQ 3KnYAM6V7te2schP3z8i8LemB9DVxBN5NTWn5FTlhhLw8KLx3VdM7SG1Qk4BZ7pFTWVe EKIusLo2tlULiwbgrZp/aIqaaKGUAaWkYGND8WODNVJD818nDuto5pYYcfZPyrZyxKZX PBUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BkZHEAhe; 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 gs18si21128294ejb.435.2020.12.28.06.56.39; Mon, 28 Dec 2020 06:57:02 -0800 (PST) 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=BkZHEAhe; 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 S2408043AbgL1OyV (ORCPT + 99 others); Mon, 28 Dec 2020 09:54:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:52136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441426AbgL1ORR (ORCPT ); Mon, 28 Dec 2020 09:17:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DCFA207B2; Mon, 28 Dec 2020 14:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165022; bh=gbZNBjrc2zlFcnWBSOD6PhrMpM+qwB4I32NGCWBDp/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkZHEAheBYSkJK+G9njY0SeAyFA2z0aRHGw0aT4Y5grrWIIfGNs/FPf/AMROlqUuN ieiG88BMCYvOMhzYgeSy1y/h6Rjv8a2k9HOMr61peKORZHYDPWiwdlGlynUvXUtBYL 15axxs3OjZAkBkQLjgvm3I8CNjiCvhUvKo543x2k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 342/717] block/rnbd: fix a null pointer dereference on dev->blk_symlink_name Date: Mon, 28 Dec 2020 13:45:40 +0100 Message-Id: <20201228125037.409803523@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Colin Ian King [ Upstream commit 733c15bd3a944b8eeaacdddf061759b6a83dd3f4 ] Currently in the case where dev->blk_symlink_name fails to be allocates the error return path attempts to set an end-of-string character to the unallocated dev->blk_symlink_name causing a null pointer dereference error. Fix this by returning with an explicity ENOMEM error (which also is missing in the original code as was not initialized). Fixes: 1eb54f8f5dd8 ("block/rnbd: client: sysfs interface functions") Signed-off-by: Colin Ian King Addresses-Coverity: ("Dereference after null check") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/rnbd/rnbd-clt-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index b53df40c9a97f..d854f057056bb 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -494,7 +494,7 @@ static int rnbd_clt_add_dev_symlink(struct rnbd_clt_dev *dev) dev->blk_symlink_name = kzalloc(len, GFP_KERNEL); if (!dev->blk_symlink_name) { rnbd_clt_err(dev, "Failed to allocate memory for blk_symlink_name\n"); - goto out_err; + return -ENOMEM; } ret = rnbd_clt_get_path_name(dev, dev->blk_symlink_name, -- 2.27.0