From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAE5A6FA0 for ; Mon, 16 Jan 2023 17:02:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E58C433D2; Mon, 16 Jan 2023 17:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673888522; bh=ZLnyO/TflFe3u2q0nVyOyx6xzsmiikcqfUE9xwC/dGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kk3FiAN3xAY3wFzePTKf7UH7RUXcYmGMMBdWtwZqSEk1wTXoYENMdbcLfPJPEJHV4 LUzXDYoyOk7kJBFQU/gCP1ycJRA+Z8TKPzroXtTLtBYiaH5a5bVkz1GK3GZSXwIRYd zFCdcfanoG5u8/sOpS/Db2oNSzSujSYDY4Erv6jQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wang Yufen , Kees Cook , Sasha Levin Subject: [PATCH 4.14 037/338] pstore/ram: Fix error return code in ramoops_probe() Date: Mon, 16 Jan 2023 16:48:30 +0100 Message-Id: <20230116154822.387166189@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154820.689115727@linuxfoundation.org> References: <20230116154820.689115727@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Wang Yufen [ Upstream commit e1fce564900f8734edf15b87f028c57e14f6e28d ] In the if (dev_of_node(dev) && !pdata) path, the "err" may be assigned a value of 0, so the error return code -EINVAL may be incorrectly set to 0. To fix set valid return code before calling to goto. Fixes: 35da60941e44 ("pstore/ram: add Device Tree bindings") Signed-off-by: Wang Yufen Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/1669969374-46582-1-git-send-email-wangyufen@huawei.com Signed-off-by: Sasha Levin --- fs/pstore/ram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 11c7a171c0a1..dc5a40058c2f 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -749,6 +749,7 @@ static int ramoops_probe(struct platform_device *pdev) /* Make sure we didn't get bogus platform data pointer. */ if (!pdata) { pr_err("NULL platform data\n"); + err = -EINVAL; goto fail_out; } @@ -756,6 +757,7 @@ static int ramoops_probe(struct platform_device *pdev) !pdata->ftrace_size && !pdata->pmsg_size)) { pr_err("The memory size and the record/console size must be " "non-zero\n"); + err = -EINVAL; goto fail_out; } -- 2.35.1