From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B81A4144D1A; Tue, 10 Sep 2024 10:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725965237; cv=none; b=XezjjhhxjtPMnpXdmqdwU8L418n/k3alX2HnQytjKFCahJ29MVgKKdWYTnLbYwpJWgw70fbgXx92dgEXrrnUlrBCWm8a3atMD1iS6kYWCJlFTj8yXGiTLuQ+76vHV6SLmo3bbR4lC9gXM+zXOyVAJ8Jgvg5e+sdOo3o6L9Ey4bE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725965237; c=relaxed/simple; bh=JeqZf57dvvK65uJnps+VfKvvzzG0otFFTobUi2svT6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SV+AQpuhYjYdIk64opxniERDiLr8S9AV5bPS2KX8COmguUCe/v+M/Gj1A4phhMPuxvFCuCM0785TiAAQ9qPJeEXscwfj7nR7rGIlqgEdZLsKMXspl4AVgZ1wZyCidEWEeWwTF0JgNQwvzfwTy+PyhDekdGcMARrv4YojWnW9FgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jICuNbO9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jICuNbO9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E172BC4CEC3; Tue, 10 Sep 2024 10:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725965237; bh=JeqZf57dvvK65uJnps+VfKvvzzG0otFFTobUi2svT6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jICuNbO9CT986qaiRnvSI/xdAoMelFTWFq0dUD5tXG2l/cst+tWNt7NwvbBQC237/ kiyFFx9XVq40ifihptLYKV1deJg8zeRn+BPzLy7lyaNzqxcHoTEf0jDqHBv3RTwQZ7 aufHZsXs5GhZyclChit0HUD7U/JjuUsO9K6kiziw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Ellerman , Damien Le Moal , Sasha Levin Subject: [PATCH 5.10 156/186] ata: pata_macio: Use WARN instead of BUG Date: Tue, 10 Sep 2024 11:34:11 +0200 Message-ID: <20240910092601.020266638@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092554.645718780@linuxfoundation.org> References: <20240910092554.645718780@linuxfoundation.org> User-Agent: quilt/0.67 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman [ Upstream commit d4bc0a264fb482b019c84fbc7202dd3cab059087 ] The overflow/underflow conditions in pata_macio_qc_prep() should never happen. But if they do there's no need to kill the system entirely, a WARN and failing the IO request should be sufficient and might allow the system to keep running. Signed-off-by: Michael Ellerman Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- drivers/ata/pata_macio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c index e47a28271f5b..ba8f0084075b 100644 --- a/drivers/ata/pata_macio.c +++ b/drivers/ata/pata_macio.c @@ -540,7 +540,8 @@ static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc) while (sg_len) { /* table overflow should never happen */ - BUG_ON (pi++ >= MAX_DCMDS); + if (WARN_ON_ONCE(pi >= MAX_DCMDS)) + return AC_ERR_SYSTEM; len = (sg_len < MAX_DBDMA_SEG) ? sg_len : MAX_DBDMA_SEG; table->command = cpu_to_le16(write ? OUTPUT_MORE: INPUT_MORE); @@ -552,11 +553,13 @@ static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc) addr += len; sg_len -= len; ++table; + ++pi; } } /* Should never happen according to Tejun */ - BUG_ON(!pi); + if (WARN_ON_ONCE(!pi)) + return AC_ERR_SYSTEM; /* Convert the last command to an input/output */ table--; -- 2.43.0