Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E1EF37F330; Thu, 20 Aug 2026 15:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238870; cv=none; b=GI6KnWcn1et3OeB3BDQCHDy77gpfRO23kkOfYGksNsvx96zsoPxoVR3vD0nd4mft6TEVkQneWqAh1FnHIFjDOzbINhWjlfaKa+HCBbi5Iu8d4aPeu7hhWHoh8eDi+p5Tus4OH5sihiqupHNNXOYVwB++zTCyPYY/AjKyB4h5mKY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238870; c=relaxed/simple; bh=4tYSLfnkMe4bsq4jE/9VjHuuI9CyAi5xlcHhV3uUYUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVeXKAfZ3409rorXI7aPiuz4wLNT6zWEdCKz02j/375Sqr4iL99nJVEgbcKHIZCnVzxRq+RN0r4wW24SnpgHEm/uuQTGCg4woWMJPgdjicCgwdo61uK9/N6Ql0suWAwp1uO2CQLkmPJ8zOu+2P4OUxes4ZYLdtYfmYa4VAAczuQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sv1+Xc3X; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sv1+Xc3X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A70D11F000E9; Thu, 20 Aug 2026 15:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787238869; bh=iZjJ91H16gtiKDsH1mMIiNVdTfC3EZCJ4Ho+b0Hcadk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sv1+Xc3XTNF/kX0C4d+qzgG9v3XKdxLcPmqyT+EKE+IZtAEu1rMZ2nCH7AyPFFW/a ElxJl+TRo0PcuTf6M5KY/qAvz+5piI6nF+3yi0KiURvPcIaA0Nz2J70rmE4dttQ2fS /esmQ7Nzkpps59Xe3hL7PFOXWpH1t/64y3pxA9mw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haibo Chen , Frank Li , Ulf Hansson Subject: [PATCH 6.18 068/217] mmc: sdhci: make tuning_err a signed int Date: Thu, 20 Aug 2026 16:53:56 +0200 Message-ID: <20260820145239.668277822@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145237.531699751@linuxfoundation.org> References: <20260820145237.531699751@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haibo Chen commit ae31bcc92bb42502bb7c9029e6dc7a824cf6cd14 upstream. Coverity report INTEGER_OVERFLOW for host->tuning_err. The tuning_err field in struct sdhci_host is used to store an error code for re-tuning, but it was declared as unsigned int. Several call sites store negative error codes into it and later compare against negative values: - sdhci.c, sdhci-of-dwcmshc.c and sdhci-pci-gli.c assign it the return value of __sdhci_execute_tuning()/__sdhci_execute_tuning_9750(), both of which return a signed int (possibly a negative errno); - sdhci-of-esdhc.c assigns host->tuning_err = -EAGAIN and later does "ret = host->tuning_err; if (ret == -EAGAIN ...)"; - sdhci-of-dwcmshc.c prints it with the %d (signed) conversion. Storing a negative errno in an unsigned int and reading it back as a signed int only happens to work because of two's-complement, same-width integer conversions. It is misleading and triggers sign-conversion warnings. All users treat the value either as a signed error code or as a boolean (zero / non-zero), so changing the type to a signed int is safe and makes the intent explicit. Fixes: 7d8bb1f46e13 ("mmc: sdhci: add tuning error codes") Assisted-by: Cline:claude-sonnet [read_file, search_files, git] Signed-off-by: Haibo Chen Reviewed-by: Frank Li Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -659,7 +659,7 @@ struct sdhci_host { unsigned int tuning_count; /* Timer count for re-tuning */ unsigned int tuning_mode; /* Re-tuning mode supported by host */ - unsigned int tuning_err; /* Error code for re-tuning */ + int tuning_err; /* Error code for re-tuning */ #define SDHCI_TUNING_MODE_1 0 #define SDHCI_TUNING_MODE_2 1 #define SDHCI_TUNING_MODE_3 2