Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp959120img; Mon, 18 Mar 2019 19:22:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxihVw1Z7G/TIQZrC8IaGsYIkgp6mgr0t4XNRLuyNTqZX3s/R8RXREa+et4vyJf/5sS7YUL X-Received: by 2002:a63:2c3:: with SMTP id 186mr3721310pgc.161.1552962120743; Mon, 18 Mar 2019 19:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552962120; cv=none; d=google.com; s=arc-20160816; b=ax46oV/nWOBKpp3AChMR/U4CYwE/xt1TdOW6yagL4U3zOmle1M4qfKm7glV//Yp7PS rya+PU+fVsL+KoHbH2cSO9KNMmJcdNHGBGSHkDJjRZXvqKE+UuKY3ZTgoGPAVF0K9Ie8 ci70tKlwQ7POf9zWAd671R4OVGcFYf0DE2imuJM4ZLVej2fSILVUqdvAJBidqVJ5AJWS rIYpWoKjqTcrgIJDYPLoVQpAOcE3308SkUvTruQt7uwdwyBge6rms3SBahrh/dBrD5bA l87pGsTE1Lv+f8iujMe1I0M5F7I9j5oCaC01hzNTU4rm7OcUHykkb/M/4mdhkqvKSllR tzTw== 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=xz8TtdHzn7FvNUl6ufCxByebYkG7gs/9oxNPLul8KYs=; b=BVKK6TFgGFDOPb/BxWnS9Cu0zPAN92inOYehfOFnmfhe/wb0u8WxoisP82F2kuCuDv 056/jbQI+xnibb4yCZAtMV6Vz1oCvjDJ+YQ2ss2YDU/qpH/t1w5kVKDqC5gLgZ+EQPM1 7O0XehE24Rn4j2jtY4kQ4dbf+XqpDwHByhe+R9qmE6eS4MLrBL1moLO6BRnBG40P2P21 WtqNEbgLsWAchFjNGaq4Fu/tRpB2L5x55rkSRTpWvaalrhulMSEtgywKw6n87YyZJBu6 qqyukUGunRKlXOoH1fif7ayMsuXxbyuYFEkeNXnUiFLLq74/vHb7qrtumaZlMVVVn+fK 7sIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="TwJp/g+z"; 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 k7si11078968pfb.69.2019.03.18.19.21.45; Mon, 18 Mar 2019 19:22:00 -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="TwJp/g+z"; 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 S1727732AbfCSCUw (ORCPT + 99 others); Mon, 18 Mar 2019 22:20:52 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42488 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbfCSCUp (ORCPT ); Mon, 18 Mar 2019 22:20:45 -0400 Received: by mail-io1-f67.google.com with SMTP id c4so16362584ioh.9 for ; Mon, 18 Mar 2019 19:20:45 -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=xz8TtdHzn7FvNUl6ufCxByebYkG7gs/9oxNPLul8KYs=; b=TwJp/g+zcBUp8Qi00b5MwP4CXkovYaSSJ7+H0OKGMnQDnVfIJi1lqMEw1GdEX5ZPGB hwdjtkFb8qCIs6uqwh1AIP2L516OCdNwY4envXeTqJppIh+sKUMQ8dsDQuVbKHb/XWs8 ns3dGZTbe79jZoszGKiiPycKkuELQ12A1lGdNTrAez/7cNEa3ph4a/TTNw02bFqMAaRi 61PfKVK99+x4z84xJ+NSHqc3NsmM5GJbij4otLMD3pH2wD1SH5QS2Cvi4QDPyYIhCfgJ /VJJDskND0Hb+y7eNlAojjbvmBTjZ8H5HNtghQGCMYyiGHYos64WXW7uvWNUVXEclMCZ eDCg== 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=xz8TtdHzn7FvNUl6ufCxByebYkG7gs/9oxNPLul8KYs=; b=j0RctaoFtyrSuSiSQcHz6N6A094u2AL/TLOjilXoGVnhkmD2D/6p/qNUT2GRA57Ptb qO+FlhECyEgyDx2FlH8CwSi/T40jshmglmaMjYdZhqs8fk5owwiF44m07Of0irq+Q938 Zw/vifVae0lC5GqQuMTddN2HRlfwvACNT4fY9sIfekJEp8j/vI7HbnqSXIfq9iorXC3n 1Epegx2kltgwHl8+7hHM/n84eziIn26wFNMPDlun+5GNAPa8Re+pqOK4Pt0ab+MRHa37 ibYo12+MVwbdwpCX01OAh3KyG4kQcEvkyk4+bB3NuppDAoTefdX7oXpxpMBNQg2T0cGy PcMg== X-Gm-Message-State: APjAAAXfvKUWvhYs1UEU2VZ3iiIKbOFJgZDvPHvG7KTtxOv2/uxIWdH/ lVbFRtzn1VDXxa7kcQY+HbSrQ0YQK6Q= X-Received: by 2002:a6b:1847:: with SMTP id 68mr39756ioy.166.1552962044758; Mon, 18 Mar 2019 19:20:44 -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 l8sm673838itl.26.2019.03.18.19.20.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 19:20:44 -0700 (PDT) From: George Hilliard To: Greg Kroah-Hartman Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, George Hilliard Subject: [PATCH v2 11/11] staging: mt7621-mmc: Only unmap_sg if mapped Date: Mon, 18 Mar 2019 20:20:12 -0600 Message-Id: <20190319022012.11051-12-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190319022012.11051-1-thirtythreeforty@gmail.com> References: <20190319022012.11051-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 A failure while processing the start command could cause dma_unmap_sg() to be called without first calling dma_map_sg(). Since calling dma_unmap_sg() is only needed when data != NULL, move the unmap call into the corresponding if {} block. Signed-off-by: George Hilliard --- drivers/staging/mt7621-mmc/sd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index b52e0284ea8e..f14ff75cc4b7 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -695,7 +695,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) /* then wait command done */ if (msdc_command_resp(host, cmd, 1, CMD_TIMEOUT) != 0) - goto done; + goto unmap; /* for read, the data coming too fast, then CRC error * start DMA no business with CRC. @@ -732,18 +732,17 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) /* Last: stop transfer */ if (data->stop) { if (msdc_do_command(host, data->stop, 0, CMD_TIMEOUT) != 0) - goto done; + goto unmap; } - } -done: - if (data) { +unmap: host->data = NULL; dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, mmc_get_dma_dir(data)); host->blksz = 0; } +done: if (mrq->cmd->error) host->error = 0x001; if (mrq->data && mrq->data->error) -- 2.21.0