From patchwork Fri Jan 27 22:30:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 9542853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33F4760415 for ; Fri, 27 Jan 2017 22:41:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2895527F07 for ; Fri, 27 Jan 2017 22:41:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C2A927FBB; Fri, 27 Jan 2017 22:41:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A855A27F07 for ; Fri, 27 Jan 2017 22:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751077AbdA0WlD (ORCPT ); Fri, 27 Jan 2017 17:41:03 -0500 Received: from mail.ispras.ru ([83.149.199.45]:36378 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbdA0WlD (ORCPT ); Fri, 27 Jan 2017 17:41:03 -0500 Received: from localhost.localdomain (ppp85-140-179-120.pppoe.mtu-net.ru [85.140.179.120]) by mail.ispras.ru (Postfix) with ESMTPSA id BC56354006D; Sat, 28 Jan 2017 01:31:57 +0300 (MSK) From: Alexey Khoroshilov To: Ondrej Zary , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Alexey Khoroshilov , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] wd719x: add check for dma mapping errors Date: Sat, 28 Jan 2017 01:30:52 +0300 Message-Id: <1485556252-10888-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP wd719x_queuecommand() doesn't check if mapping dma memory succeed. The patch adds the check and failure handling. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/scsi/wd719x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 2a9da2e0ea6b..41ddbdcf02e0 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -244,6 +244,12 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) scb->sense_buf_length = SCSI_SENSE_BUFFERSIZE; cmd->SCp.dma_handle = dma_map_single(&wd->pdev->dev, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(&wd->pdev->dev, cmd->SCp.dma_handle)) { + dev_err(&wd->pdev->dev, "unable to map dma\n"); + wd719x_finish_cmd(cmd, DID_ERROR); + spin_unlock_irqrestore(wd->sh->host_lock, flags); + return 0; + } scb->sense_buf = cpu_to_le32(cmd->SCp.dma_handle); /* request autosense */