diff options
author | Justin Stitt <justinstitt@google.com> | 2023-12-13 00:19:06 +0100 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2023-12-14 04:25:00 +0100 |
commit | edc22a7c86888d1f2442e359c3b33a861045e9cd (patch) | |
tree | 5842ecbd09156c0ed798ebcb6b12640ec1fb0116 /drivers/ufs | |
parent | Merge patch series "lpfc: Update lpfc to revision 14.2.0.17" (diff) | |
download | linux-edc22a7c86888d1f2442e359c3b33a861045e9cd.tar.xz linux-edc22a7c86888d1f2442e359c3b33a861045e9cd.zip |
scsi: fcoe: Use sysfs_match_string() over fcoe_parse_mode()
Instead of copying @buf into a new buffer and carefully managing its
newline/null-terminating status, we can just use sysfs_match_string() as it
uses sysfs_streq() internally which handles newline/null-term:
| /**
| * sysfs_streq - return true if strings are equal, modulo trailing newline
| * @s1: one string
| * @s2: another string
| *
| * This routine returns true iff two strings are equal, treating both
| * NUL and newline-then-NUL as equivalent string terminations. It's
| * geared for use with sysfs input strings, which generally terminate
| * with newlines but are compared against values without newlines.
| */
| bool sysfs_streq(const char *s1, const char *s2)
| ...
Then entirely drop the now unused fcoe_parse_mode(), being careful to
change if condition from checking for FIP_CONN_TYPE_UNKNOWN to < 0 as
sysfs_match_string() can return -EINVAL. Also check explicitly if
ctlr->mode is equal to FIP_CONN_TYPE_UNKNOWN -- this is probably preferred
to "<=" as the behavior is more obvious while maintaining functionality.
To get the compiler not to complain, make fip_conn_type_names const char *
const. Perhaps, this should also be done for fcf_state_names.
This also removes an instance of strncpy() which helps [1].
Link: https://github.com/KSPP/linux/issues/90 [1]
Cc: <linux-hardening@vger.kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231212-strncpy-drivers-scsi-fcoe-fcoe_sysfs-c-v2-1-1f2d6b2fc409@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/ufs')
0 files changed, 0 insertions, 0 deletions