misc: mods: null-terminate strings from userspace

Bug 3952896
Bug 3959323

Change-Id: Id85f6dd605d99e1fec6a6bd261940268cafafa34
Signed-off-by: Chris Dragan <kdragan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2860841
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Chris Dragan
2023-02-20 05:31:35 -08:00
committed by Laxman Dewangan
parent 9ac86753e5
commit 74ee35918c

View File

@@ -2,7 +2,7 @@
/*
* This file is part of NVIDIA MODS kernel driver.
*
* Copyright (c) 2008-2022, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2008-2023, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA MODS kernel driver is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License,
@@ -1569,15 +1569,21 @@ int esc_mods_irq_handled(struct mods_client *client,
int esc_mods_map_irq(struct mods_client *client,
struct MODS_DT_INFO *p)
{
/* irq parameters */
struct of_phandle_args oirq;
/* platform device handle */
struct platform_device *pdev = NULL;
struct device_node *np;
int err = 0;
/* the physical irq */
int hwirq;
/* platform device handle */
struct platform_device *pdev = NULL;
/* irq parameters */
struct of_phandle_args oirq;
/* Make sure strings from userspace are null-terminated */
p->dt_name[sizeof(p->dt_name) - 1] = 0;
p->full_name[sizeof(p->full_name) - 1] = 0;
/* Search for the node by device tree name */
struct device_node *np = of_find_node_by_name(NULL, p->dt_name);
np = of_find_node_by_name(NULL, p->dt_name);
if (!np) {
cl_error("node %s is not valid\n", p->full_name);
@@ -1652,11 +1658,16 @@ int esc_mods_map_irq_to_gpio(struct mods_client *client,
struct MODS_GPIO_INFO *p)
{
//TODO: Make sure you are allocating gpio properly
struct device_node *np;
int gpio_handle;
int irq;
int err = 0;
struct device_node *np = of_find_node_by_name(NULL, p->dt_name);
/* Make sure strings from userspace are null-terminated */
p->dt_name[sizeof(p->dt_name) - 1] = 0;
p->full_name[sizeof(p->full_name) - 1] = 0;
np = of_find_node_by_name(NULL, p->dt_name);
if (!np) {
cl_error("node %s is not valid\n", p->full_name);