From nobody Mon Sep 28 17:48:36 2026 Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E737C3A5E98 for ; Wed, 19 Aug 2026 22:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787177009; cv=none; b=CZgcDH/lHbhtG5md1oCvtOyC0Ji0czZsAKJ27bjrMMh6k/5rlr5Zk4aDqGWhhsYS+NVCqCy7HLYLIy5WP6RsnqB1r4+8nQHr4piN5kmDjEWpbGV7VLTjjdAhK8+0xqVDOg1wzRQXbnVQNYkNQs498I7doeNZWnqkX+hFi/HIrCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787177009; c=relaxed/simple; bh=D6VaASqwH1nGEidAP/2Rt92bNOLS9oYB2L7E8psNPhw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rYKnmDcJ/NZc2qWaSLGh7Fx3hIRFaoykO3hRcE4ySe672qEheveQRGOGHwBBhk6/M9ok/nEuCDPQ/aZZWDsBNRsuzo7t+F7myBs4sF56ICGuG1TXUervWPC+q6DD5siguY1xeYy2zP8E+znLz2syZHnFFNBsKEnYOJHaH1MH2g8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EHe7yhNS; arc=none smtp.client-ip=209.85.221.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EHe7yhNS" Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-5bfb3347ce0so707501e0c.2 for ; Wed, 19 Aug 2026 15:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787177005; x=1787781805; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=HhkyAwn7RmyLaDPVRMZZw5dHSW6ePghk6etlcD4cNrY=; b=EHe7yhNSvEMxJMvSMMme32eD3WOGY++20/XRP59MRUVZ6sifoVP7Qjk5Sll9+Cr3fH e8C1xB6SlTKODfcqFOTjMkdBsvwbcYAZXEb4JtAgyBdeYJEz3PYDq8VNxk23fgMk3udN MEYtdAZ6lUG/+dAxzRIYNnBmN0tVBby/gl26XfEanYQlWWXfyKmD1p8LZfRJDWTUqr7z QwTC2q+Si0GQV/320vR3hpEI/34swacsyh3GwEjIq9PvAfvUmQ69tT+3FU8i8XXmWN/L P4gWK1NEShdVmQRf5frOe7kEKtZXOX2vvQmiP0gG79xZoA5d8SXv/5tGDx/nTXTQtRGy 1vPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787177005; x=1787781805; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HhkyAwn7RmyLaDPVRMZZw5dHSW6ePghk6etlcD4cNrY=; b=dZE+ilD9fkv5GAeJpnN3CjfwV9Wz7INW8B1GM4JnefjOewqpUlxHRHRhr80Z6ZdE6a attpflDLVocxVOBdeHOyga48z46l6brKfmZoyaPswlVFivkNRI2alFtnDzMyQmEEXC3f qeEa4I5pHuBNzm4BkIwdCVrufX8MJfQhDcTI9Qr0rw36NpduyaLZGCG+UvThE/dF258z CZ6422t2+F5eisB3TeZh/v6yb4e5TwrwtsQKQn4/Lm7aaAZD6gRT78AeRkbfLrqAfX7S MPTmdctfoN5+x4B6MVHEM5Q8OjKQ8zTuvU7Z86AE9LHhIs5atAY+sU4AxbyA6uK6Wezl Wr4w== X-Forwarded-Encrypted: i=1; AHgh+RrHR6kN7Re4RwhcoLFuV8MebFQOCy5hQBruOq/3LPTH0YAMv5CIIfpNe50MHAHBdv0NHJz1AQa8U+2yVbY=@vger.kernel.org X-Gm-Message-State: AOJu0YyfBhYMDsCmjT8y41EputddIh7ynF07oJKO5isR4Y0yfHL+P259 pmU6ZFSOP/XvJfooQ9kKDxDhIl6br2sG3ge1Ov1txl+1lQdYNjfIVqzh X-Gm-Gg: AR+sD11sF2nGiocz7lIrlM9nrnRXTmwWyY01BVbEJsZeY0Mv7GsSwWTYqPpK/H0b3Qs AbHZLF0LsKVI+uCuZiORh7Pfq4o7CaYYA3V3c2VbfzLAqd/piP0RlU9ft7dKPUFs+VNVVnAh5Gg NS+SzIuoEO0HSeHyBZ9And2mOSZAXhc34/9eX4uPDZYLzVICJN4wY/A/hK+PH+9ax3BYN2Uvh27 +cQFlLUE7Ysp+7VfSMfEdboIp0nUWU01uvzI6S5mcfxRDoIxjo2PhL6Cqw8vzFuQL+VT8doTcGz 6/jsF/n2FSNSeB+ouSULvLtftz64Nd3X5je5BXBJl+IfQF/yn6dnH7dP1ZfCBuDHoPels87r0pD 80c7RY7sQvfnBcDlxy1s4lRYC7l2aRbHMwWtlYv/t1Pa6f6aML12r/QaDJlRwNU+TpTAvy3OOTQ HF779HEvKWNXs+etg/QufoSfuDuVVlUpZsDPM1t7UA2F5nr/i7luUIEvSQWMr33y6NmLki8PMGB xa3jEdiSOJL0JZN5oGxNKbCVzwWkU2ytUpngC8mqQg= X-Received: by 2002:a05:6122:4694:b0:5c0:fb8d:9993 with SMTP id 71dfb90a1353d-5c5e2ea3024mr2521414e0c.0.1787177005379; Wed, 19 Aug 2026 15:03:25 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:4c64:82a2:3443:53b2:2e07:b3bf]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c5e2617f06sm3698401e0c.6.2026.08.19.15.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 15:03:24 -0700 (PDT) From: Rodrigo Gobbi To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: ~lkcamp/patches@lists.sr.ht, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: csiostor: fix inverted sscanf() check in csio_store_dbg_level Date: Wed, 19 Aug 2026 18:58:57 -0300 Message-ID: <20260819220318.176167-1-rodrigo.gobbi.7@gmail.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" csio_store_dbg_level() has an inverted return check on sscanf(): the existing check treats a truthy return as an error, so every valid write to the "dbg_level" sysfs attribute was rejected with -EINVAL. This has been broken since the driver was first added. checkpatch also flags this same line for a related issue: WARNING: unchecked sscanf return value WARNING: Prefer kstrto to single variable sscanf Replace the sscanf()/isdigit() combo with kstrtou32(buf, 16, ...), so this class of inversion bug can't happen again. It also validates the whole string instead of stopping at the first non-digit. This makes the isdigit() pre-check redundant, so it's removed along with the now unused include. Base 16 is used instead of base 0 (which would only recognize hex with an explicit "0x" prefix) to match csio_show_dbg_level(), which always prints the value as bare hex via "%x". This keeps read and write symmetric: writing back what was just read always restores the same value. Fixes: a3667aaed569 ("[SCSI] csiostor: Chelsio FCoE offload driver") Signed-off-by: Rodrigo Gobbi --- Hi all, While looking at this file I noticed checkpatch flags csio_store_dbg_level() with: WARNING: unchecked sscanf return value WARNING: Prefer kstrto to single variable sscanf Digging into it, the sscanf() check is actually inverted, so csio_store_dbg_level() has been rejecting every valid write since the driver was added. This patch fixes that with kstrtou32(), using base 16 (instead of 0) so that copy-pasting the value printed by csio_show_dbg_level() (which is always printed as bare hex) back into the store function round-trips correctly. While tracing this I also noticed that log_level doesn't seem to be read anywhere else in the driver to gate any behaviour -- I couldn't find a consumer for it. I'm not proposing to remove the dbg_level sysfs attribute as part of this fix, just flagging it in case it's dead code worth a separate cleanup, if the maintainers agree. I wasn't able to test this patch, only compile it. Thanks and regards. --- drivers/scsi/csiostor/csio_scsi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio= _scsi.c index b1de615cf316..d64b47ee1bbe 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -34,7 +34,6 @@ =20 #include #include -#include #include #include #include @@ -1441,12 +1440,11 @@ csio_store_dbg_level(struct device *dev, struct csio_lnode *ln =3D shost_priv(class_to_shost(dev)); struct csio_hw *hw =3D csio_lnode_to_hw(ln); uint32_t dbg_level =3D 0; + int ret; =20 - if (!isdigit(buf[0])) - return -EINVAL; - - if (sscanf(buf, "%i", &dbg_level)) - return -EINVAL; + ret =3D kstrtou32(buf, 16, &dbg_level); + if (ret) + return ret; =20 ln->params.log_level =3D dbg_level; hw->params.log_level =3D dbg_level; --=20 2.48.1