Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp182673imp; Tue, 19 Feb 2019 21:19:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbblBCPexN214KDeUUthoZGunuQtmGPk4lD7we97ytO+Jc2Htzz3Rppv3/XJ/CCdhE0OKAS X-Received: by 2002:a17:902:bc88:: with SMTP id bb8mr35233335plb.12.1550639964944; Tue, 19 Feb 2019 21:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550639964; cv=none; d=google.com; s=arc-20160816; b=G58LKEdezFSj4h2/IH3YwyeKTiKUezl37ZXnCQED5DmOlsY3L8E5CSrbVnpvMyCTHc y7rc5F0F/QJogibJO24qahm9k4wFZWhOHOoThSgL+aWCa6G6fXtGVpfL+ShaPBHkmjqu R1QtE8p+zOsv4YMtvYSXflBJh9Bf4RydrVIzjwrX3QOkEUkB4t3kuL3BdMoiGilLZoEG lyjRNOiPGzN7zDYRy+i4JBwX0OZPH4LSwEBHNNEwda4frt+5d7qUDAsrxMgyY9keJlUE FL5ryXngyudmfuVscB4MUVs+PK3h2jU0vbW/kH3gzL+tITimO8IvrvoZjkMa+k2ek/Se Czaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y4yMs6hMqtvvahMCzASAJoZSo4lJex4Sz2Dn5yBReks=; b=pGnJvfA2dh66X9NHYCGea5wmRRJNnpd0m92OSDnYlcX90SrgmfsL3qK4liVVna8YvP Os44VP+ibmqk8KLjDu/8Yx0eilLX7PbYXvzAHYptYZycEe6WU1Hwcbf6kOqaCmrNyQf8 rrMvYctMjpHiAd4YAiGr2xduHFwEf08nFJdF+/r0J9fWWhIkYqOUpn4oVbnMvp5e77uN 5MDO/UcAG1QR9eSk/93WT0r4YE1apyeMNLrVHpIL7Iv8Jg29wi5stwIS4YUiYe2d51NZ Dx9S/d8pNRNPKFLzs4X19DuUHivmdeajsr2dAYhnAPYiSL4I9rUZiZ6L/W+my9bONZoD fxzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GX1ajfFp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si17552447pgx.462.2019.02.19.21.19.10; Tue, 19 Feb 2019 21:19:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GX1ajfFp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbfBTFSb (ORCPT + 99 others); Wed, 20 Feb 2019 00:18:31 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:36872 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbfBTFSP (ORCPT ); Wed, 20 Feb 2019 00:18:15 -0500 Received: by mail-it1-f193.google.com with SMTP id z124so12678650itc.2 for ; Tue, 19 Feb 2019 21:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y4yMs6hMqtvvahMCzASAJoZSo4lJex4Sz2Dn5yBReks=; b=GX1ajfFpPX3dsFo72S7pW/PMfXxzSgfIp9vu8dvVBCXLMw4UNg6NfUlBPfiAzR4bYW DFBpWdVe91cdXaohtmMZ6KwvpdHYlDGPF309YLcrIigvhr3zGa1ZnvXNuMYVAbJhPzdr ZbyuTHxMehoFFPcdlDc964ax2J7Vn4WAyYuEe4Je2fjWEctCq7TXYq5ZKYON6PQript7 4eBhmeaGm8y8vK1FVbGZIqRXVWb9NiV3iSbD3oV6AIE8qa8DsDrvjUnOq4bkiICsR9R4 RZ3eNeuR8+mLg2oz7kr4+zvZx+4QjECsK4jp3FVete795spMOHgittlO5BRim05UubTR unVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y4yMs6hMqtvvahMCzASAJoZSo4lJex4Sz2Dn5yBReks=; b=h3ZfGJf8C3MsgP49eR2rUXJYlLd+LFC5DdNfqCqP4+C5FbPPIh+5tus4SzSidX7eOR UuMuMHVIKVrDwdIyLkhxcqxfiJLgsG7lLkOgArRfqWaigFIaADXSCCVSI8P3IUQgRZnQ JQWO7EKcnxJQnSm1/1r2m/VzZrm9KbcQdatWhbPJSazdSvdYOQHLooXM/N+RRrD/pwtW 4INnFDxVrmqY9M7yoN0oKyfeaeK60T9jISMsxPER77/OgWP8TsBYq6tyDlTZBgj5CF6V zVl7WlpfJ6UWKcee/aJZHcte8q+6d/x4GZQVN5AtL+RgGIar7rhubrI8joHK0kaVkJGS wbdQ== X-Gm-Message-State: AHQUAuZxtprWfhhK8EEDRzh/lSqd5Fke9IhBTw4iMWK2N61I1vAb1c3W lTAUU6eDkhWiQGrZJ2jZul0= X-Received: by 2002:a24:6890:: with SMTP id v138mr4495624itb.53.1550639895043; Tue, 19 Feb 2019 21:18:15 -0800 (PST) Received: from localhost.localdomain (c-73-242-244-99.hsd1.nm.comcast.net. [73.242.244.99]) by smtp.gmail.com with ESMTPSA id k64sm2297550itb.7.2019.02.19.21.18.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 21:18:14 -0800 (PST) From: George Hilliard To: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org, Neil Brown , George Hilliard Subject: [PATCH 08/10] staging: mt7621-mmc: Check for nonzero number of scatterlist entries Date: Tue, 19 Feb 2019 22:17:52 -0700 Message-Id: <20190220051754.12195-9-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220051754.12195-1-thirtythreeforty@gmail.com> References: <20190220051754.12195-1-thirtythreeforty@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The buffer descriptor setup loop is correct only if it is setting up at least one bd struct. Besides, there is an error somewhere if dma_map_sg() returns 0. So add a paranoid check for this condition. Signed-off-by: George Hilliard --- drivers/staging/mt7621-mmc/sd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 942c0d63d710..736e1d23b391 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -594,7 +594,12 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, struct bd *bd; u32 j; - BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ + // Shouldn't happen; we configure the mmc host layer + // based on MAX_BD_NUM: + BUG_ON(sglen > MAX_BD_NUM); + // Correct setup below requires at least one bd + // (and dma_map_sg should not return 0): + BUG_ON(sglen == 0); gpd = dma->gpd; bd = dma->bd; -- 2.20.1