Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1759048rdd; Thu, 11 Jan 2024 08:26:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb9aaU/bko6aJsvLKqEHtL0mNoMR8aEv8BXLPcFo4nxfzLZXbc8sNqcyO9+G8HvBa+P4QF X-Received: by 2002:a05:6214:e49:b0:680:cd23:83f3 with SMTP id o9-20020a0562140e4900b00680cd2383f3mr113572qvc.13.1704990374242; Thu, 11 Jan 2024 08:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704990374; cv=none; d=google.com; s=arc-20160816; b=R7D+NPeupjUPL8+FtEoVukn2hV85hCd3+O6rIsJ1ILfPmLC+J0s1Qb7S1rTdrQe2G5 FUq8/UPnv9hdBDooR2OhZuVBGZAkqkpvgELqnQjSrGlQay3YO2mSTNFLlfvzOuHWTvva pZgEMj7UYLeqrIn1L0WMBdQBCdk8P9WkiIuZlScp6TVN+36yJEJM16KISmejn9aEYpz9 hekVpN70nXBB6z9aIdf0hj/BK0cxsrEjtRuyQNx6nvsFxun2tMYTJTVgT5J1syUwVGlz w1r3yHck49eFerMrpZaLEa7ebElzfwWD114/9sN/uTx7GF2B3uTwUWJX/SbVzUrEJpYW 9ffw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=MMA7Jf2m2884PIJudPkb8VYRI5Ehzqro2oR8+njB8z4=; fh=su8HbMDBUUpWtyQIM2T+xFkZpPnduuhXZs1gvoTRGUQ=; b=Z7Qo+v+BuzFR8sefCAWLY1qO02gdDnq9QaLD01omqI/q+b1XWaMZMtm9V3IF4j1vc7 sV3XwTIkIE5YptAfwJ+Fg57zslcFfLac3HVWACBnpfTAwaSgAoKjTL8aMCQVZbO0IUnU kVYBW53pVW590dMovnM6HRzJGACT3hfMdie6ifClXmvSg9RDR+vTzF8YGOoyxFCydcMz G242mhM7EP4p75t9N4eQjNZDFj4vazLdlbFjwUrZKw5zKZ2fUBoRYTTqgh7eYZeUPpXm 5cJ9wB/usDFrbAOzexXclXr5Y12IeWe+xwxRKpCDPLqipxhQuG68wgUGDbxTc0qTFwwz Fuzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=omZcBp3P; dkim=pass header.i=@suse.com header.s=susede1 header.b=daFQmSRg; spf=pass (google.com: domain of linux-kernel+bounces-23861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t1-20020a0cc441000000b0067f0cf9a77asi1137079qvi.77.2024.01.11.08.26.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 08:26:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=omZcBp3P; dkim=pass header.i=@suse.com header.s=susede1 header.b=daFQmSRg; spf=pass (google.com: domain of linux-kernel+bounces-23861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 625391C26233 for ; Thu, 11 Jan 2024 16:25:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 614A950267; Thu, 11 Jan 2024 16:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="omZcBp3P"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="daFQmSRg" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 D93114F8B4; Thu, 11 Jan 2024 16:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from alley.prg2.suse.org (unknown [10.100.208.146]) by smtp-out1.suse.de (Postfix) with ESMTP id 17335220B5; Thu, 11 Jan 2024 16:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704990304; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MMA7Jf2m2884PIJudPkb8VYRI5Ehzqro2oR8+njB8z4=; b=omZcBp3PMMiuePhg0CoAme0EZOLLnvHGorGhuiXqdUVzHueKRVJ1S2cm5yB0Os4jyw9+II XT72E5G0QG/k/0Z7BNYHJrPgzDdYruiO3660Q62T0cXLs0qG4FGl0aXYPRmUkNy9ciLr15 98/z84jcsljzuhiBTTmPG8EpkqzFxdg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704990302; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MMA7Jf2m2884PIJudPkb8VYRI5Ehzqro2oR8+njB8z4=; b=daFQmSRgfXmQ2xfQHqCLhVDEGrQjfY/3zISaoPq23AIbJc831A9PTJZFzLrNFKJaZT0gRf D12i9akvlzYmBsZoBrp0dT/6avOUJ2QMDNOOY+192RW2ZJqVSNknymCOZ09q4d4NuPmcxZ jEnjmMx1rP6nI6BUHA1jTxasaNOyiMU= From: Petr Mladek To: "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Down , oe-kbuild-all@lists.linux.dev, Petr Mladek , kernel test robot Subject: [PATCH] scsi: core: Safe warning about bad dev info string Date: Thu, 11 Jan 2024 17:24:19 +0100 Message-ID: <20240111162419.12406-1-pmladek@suse.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [4.90 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,intel.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+] X-Spam-Level: **** X-Spam-Score: 4.90 X-Spam-Flag: NO Both "model" and "strflags" are passed to "%s" even when one or both are NULL. It is safe because vsprintf() would detect the NULL pointer and print "(null)". But it is a kernel-specific feature and compiler warns about it: In file included from include/linux/kernel.h:19, from arch/x86/include/asm/percpu.h:27, from arch/x86/include/asm/current.h:6, from include/linux/sched.h:12, from include/linux/blkdev.h:5, from drivers/scsi/scsi_devinfo.c:3: drivers/scsi/scsi_devinfo.c: In function 'scsi_dev_info_list_add_str': >> include/linux/printk.h:434:44: warning: '%s' directive argument is null [-Wformat-overflow=] 434 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) | ^ include/linux/printk.h:430:3: note: in definition of macro 'printk_index_wrap' 430 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~~~~ drivers/scsi/scsi_devinfo.c:551:4: note: in expansion of macro 'printk' 551 | printk(KERN_ERR "%s: bad dev info string '%s' '%s'" | ^~~~~~ drivers/scsi/scsi_devinfo.c:552:14: note: format string is defined here 552 | " '%s'\n", __func__, vendor, model, | ^~ Do not rely on the kernel specific behavior and print the message a safe way. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401112002.AOjwMNM0-lkp@intel.com/ Signed-off-by: Petr Mladek --- Note: The patch is only compile tested. drivers/scsi/scsi_devinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 3fcaf10a9dfe..ba7237e83863 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -551,9 +551,9 @@ static int scsi_dev_info_list_add_str(char *dev_list) if (model) strflags = strsep(&next, next_check); if (!model || !strflags) { - printk(KERN_ERR "%s: bad dev info string '%s' '%s'" - " '%s'\n", __func__, vendor, model, - strflags); + pr_err("%s: bad dev info string '%s' '%s' '%s'\n", + __func__, vendor, model ? model : "", + strflags ? strflags : ""); res = -EINVAL; } else res = scsi_dev_info_list_add(0 /* compatible */, vendor, -- 2.43.0