diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_debugfs.c')
| -rw-r--r-- | drivers/scsi/lpfc/lpfc_debugfs.c | 9 | 
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index f5252e45a48a..bdf34af4ef36 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c @@ -1,7 +1,7 @@  /*******************************************************************   * This file is part of the Emulex Linux Device Driver for         *   * Fibre Channel Host Bus Adapters.                                * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *   * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  *   * Copyright (C) 2007-2015 Emulex.  All rights reserved.           *   * EMULEX and SLI are trademarks of Emulex.                        * @@ -2157,10 +2157,13 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,  	char mybuf[64];  	char *pbuf;  	int i; +	size_t bsize;  	memset(mybuf, 0, sizeof(mybuf)); -	if (copy_from_user(mybuf, buf, nbytes)) +	bsize = min(nbytes, (sizeof(mybuf) - 1)); + +	if (copy_from_user(mybuf, buf, bsize))  		return -EFAULT;  	pbuf = &mybuf[0]; @@ -2181,7 +2184,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,  			qp->lock_conflict.wq_access = 0;  		}  	} -	return nbytes; +	return bsize;  }  #endif  |