Skip to content

Commit 567a1e8

Browse files
harshimogalapallimartinkpetersen
authored andcommitted
scsi: fcoe: Fix unsigned comparison with zero in store_ctlr_mode()
ctlr->mode is of unsigned type, it is never less than zero. Fix this by using an extra variable called 'res', to store return value from sysfs_match_string() and assign that to ctlr->mode on the success path. Fixes: edc22a7 ("scsi: fcoe: Use sysfs_match_string() over fcoe_parse_mode()") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Link: https://lore.kernel.org/r/20240102085245.600570-1-harshit.m.mogalapalli@oracle.com Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 904fdd2 commit 567a1e8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/scsi/fcoe/fcoe_sysfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ static ssize_t store_ctlr_mode(struct device *dev,
263263
const char *buf, size_t count)
264264
{
265265
struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
266+
int res;
266267

267268
if (count > FCOE_MAX_MODENAME_LEN)
268269
return -EINVAL;
@@ -279,12 +280,13 @@ static ssize_t store_ctlr_mode(struct device *dev,
279280
return -ENOTSUPP;
280281
}
281282

282-
ctlr->mode = sysfs_match_string(fip_conn_type_names, buf);
283-
if (ctlr->mode < 0 || ctlr->mode == FIP_CONN_TYPE_UNKNOWN) {
283+
res = sysfs_match_string(fip_conn_type_names, buf);
284+
if (res < 0 || res == FIP_CONN_TYPE_UNKNOWN) {
284285
LIBFCOE_SYSFS_DBG(ctlr, "Unknown mode %s provided.\n",
285286
buf);
286287
return -EINVAL;
287288
}
289+
ctlr->mode = res;
288290

289291
ctlr->f->set_fcoe_ctlr_mode(ctlr);
290292
LIBFCOE_SYSFS_DBG(ctlr, "Mode changed to %s.\n", buf);

0 commit comments

Comments
 (0)