Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp124372img; Wed, 20 Mar 2019 15:44:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7QrAmolHkNFWJkrFTsGNzgG9jCgmjWnd1oWGT+27f+snh6BXpF9akATJ8/lobN9JTWBka X-Received: by 2002:a63:1f52:: with SMTP id q18mr421953pgm.134.1553121897632; Wed, 20 Mar 2019 15:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553121897; cv=none; d=google.com; s=arc-20160816; b=ByLkuIS6gAAXPmjWq/StOgFX/iLFox8/8G0NEtsX5eKzKb8KfFr8voExnUiRmlttz5 VAckOhNc5Y3GR4wIadNxfSEkbdS0pJGRi227lYBqLPaeJmzOKUJAgnpr1KBKXaBm3ZCR 75sOTG/ob6llJSqDlyq0Lg26TroB0f1wL0OOgFS0o7ZaVxJI+DLUBVkDH81pe+pq/fap FMEKsqBtlCOsKVtaEtV62jkJhVNKxyD9ChNhmM5jpYZS7h0qwTIVty6E3XmSZ9nR85hG rFgzrHTiC+nLwrh9k0e019IEZuN87l7Bz78p+w1Zg+a47f8DyLSEueApZ5wmd0DhtoaG wOig== 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=w4+a/5JHlT/sDlQcCOXC1KgzYcp4fkhfEGjcyXNTq50=; b=n2LueAQ3HhMIMMJr2wbRSOoYZOH5Pxj5/zF/83Sj5gULI4jzYyaqY1kRLPOjZx6I73 YlyZbAyGowTrCWkT/eFxLSwbfEmF9aNJcGCgDxNz4r1QmzvLZ06VgsZGHP09yT10Tpbp vYPXdjcp9Fd+GtpY/0sqfhyDYVytnn4TLS5CQ6fxARzxLNpTnJNLu2nfLeYTsAldDmrc GP+PJ5pJdvRWEUw/3SGglBylmZKsnoCo4pSrSygiQJG9U4tGlMjeqKq9ht43tje4uhKa vhfvAbKSYPMtqTU5yLLTdm067ijI+sbd3tkJ4KFGnLPcDEQcysVADU0wTq/92WiBkZKw 7+pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OhvZzEBN; 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 f17si2677714pgb.231.2019.03.20.15.44.42; Wed, 20 Mar 2019 15:44:57 -0700 (PDT) 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=OhvZzEBN; 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 S1727695AbfCTWoF (ORCPT + 99 others); Wed, 20 Mar 2019 18:44:05 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:52168 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727671AbfCTWoB (ORCPT ); Wed, 20 Mar 2019 18:44:01 -0400 Received: by mail-it1-f196.google.com with SMTP id e24so1547586itl.1 for ; Wed, 20 Mar 2019 15:44:00 -0700 (PDT) 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=w4+a/5JHlT/sDlQcCOXC1KgzYcp4fkhfEGjcyXNTq50=; b=OhvZzEBNYwuQff9stfVfRKeq5eFD6BLwWvLJBYxlTgJrJwOyfFQi27emUxeifdd1Wm 0K5KU0j1lq3Y9OFP/V29dImiiitoUiKRs9f1LBgNmK7nO2ynEGKXj0snu4fhlSVu+RY4 3CgZwGNm1Y+myKOw1SxzSyqMLfQ9zHNrqnh3/XsdantAZvL6Qx7a+Yq37MTCD2LUT82c HheayY+kZddd6RSyFXbNXSZXkZuKryd9jmH6XK9xZ6k9MeBBDjojPGDsSdqA0yGQv51W uQGblqWbyYxtz49/mHK7kWP5DsorjhxjtPJZlzw9+M3DGQYzdgiM6DRHKUyAY58Qoojj 9tvg== 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=w4+a/5JHlT/sDlQcCOXC1KgzYcp4fkhfEGjcyXNTq50=; b=cKu8xZGLcWX8mkLCsgq9GvOjQr5BHyZUc2NrMmCR9dfNnkxsoSYNtCNXLunHxOA8n2 rZHKrN0vkZQU42Fv+PbRNL9eq6s+61cuKfaCLAXT5LGWzroXMkSNmFL0aukQe6CvckKJ TCdGgsxOHJ/Py5rcXM1+UHSeozFb3sWoJ5rk3VOYYAsZrc+9MkAlGvBmf9lbwk56+Xlc jd51rbt5owuamm3nbY9ZMzHKZ2JOAzDCuuCzHL9ZSj44LnH9J2m410uJfK5jSGV9HoIZ 2TkiMjaBYsrmMjxeegDRA0F7eP2ibuvRSTEfsfIc48URdzCGtKOuBH1v7e0fRBQOYZzP p3Eg== X-Gm-Message-State: APjAAAUjgEGIluQStVU6s3FCeF9aFA5HjqUPmYgQbd/laHEOMauymJpP TnCD7LM2k/dkwU+nO72AQ655COctrLw5hg== X-Received: by 2002:a05:660c:9c3:: with SMTP id i3mr501255itl.168.1553121839711; Wed, 20 Mar 2019 15:43:59 -0700 (PDT) Received: from localhost.localdomain (c-73-242-244-99.hsd1.nm.comcast.net. [73.242.244.99]) by smtp.gmail.com with ESMTPSA id 139sm1805554itk.28.2019.03.20.15.43.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 15:43:59 -0700 (PDT) From: George Hilliard To: Greg Kroah-Hartman Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, George Hilliard Subject: [PATCH v3 3/3] staging: mt7621-mmc: Check for nonzero number of scatterlist entries Date: Wed, 20 Mar 2019 16:42:05 -0600 Message-Id: <20190320224204.10243-4-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320224204.10243-1-thirtythreeforty@gmail.com> References: <20190320224204.10243-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 if dma_map_sg() returns 0, which is possible and must be handled. Additionally, remove the BUG_ON() checking sglen, which is unnecessary because we configure DMA with that constraint during init. Signed-off-by: George Hilliard --- v2: Rebased v1 v3: Remove existing and added BUG_ON() in v2, and handle dma_map_sg failure gracefully. drivers/staging/mt7621-mmc/sd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 139533606863..cf2ad06112eb 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -593,8 +593,6 @@ 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 */ - gpd = dma->gpd; bd = dma->bd; @@ -687,6 +685,13 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, mmc_get_dma_dir(data)); + + if (data->sg_count == 0) { + dev_err(mmc_dev(host->mmc), "failed to map DMA for transfer\n"); + data->error = -ENOMEM; + goto done; + } + msdc_dma_setup(host, &host->dma, data->sg, data->sg_count); -- 2.21.0