From patchwork Sat Jan 28 11:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 648380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35DA3C38142 for ; Sat, 28 Jan 2023 11:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbjA1LIn (ORCPT ); Sat, 28 Jan 2023 06:08:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231767AbjA1LIm (ORCPT ); Sat, 28 Jan 2023 06:08:42 -0500 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92FAC1EFC5; Sat, 28 Jan 2023 03:08:40 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowADX3fUyAtVjDVKxAg--.49694S2; Sat, 28 Jan 2023 19:08:34 +0800 (CST) From: Jiasheng Jiang To: yanaijie@huawei.com Cc: jejb@linux.ibm.com, martin.petersen@oracle.com, john.garry@huawei.com, damien.lemoal@wdc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] scsi: aic94xx: Add missing check for dma_map_single Date: Sat, 28 Jan 2023 19:08:32 +0800 Message-Id: <20230128110832.6792-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowADX3fUyAtVjDVKxAg--.49694S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Gr15ZF1DZw4xZF1UCrWfZrb_yoWfKFb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si@vger.kernel.org Add check for dma_map_single and return error if it fails in order to avoid invalid dma address. Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver") Signed-off-by: Jiasheng Jiang --- drivers/scsi/aic94xx/aic94xx_task.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c index ed119a3f6f2e..7f0208300110 100644 --- a/drivers/scsi/aic94xx/aic94xx_task.c +++ b/drivers/scsi/aic94xx/aic94xx_task.c @@ -50,6 +50,9 @@ static int asd_map_scatterlist(struct sas_task *task, dma_addr_t dma = dma_map_single(&asd_ha->pcidev->dev, p, task->total_xfer_len, task->data_dir); + if (dma_mapping_error(&asd_ha->pcidev->dev, dma)) + return -ENOMEM; + sg_arr[0].bus_addr = cpu_to_le64((u64)dma); sg_arr[0].size = cpu_to_le32(task->total_xfer_len); sg_arr[0].flags |= ASD_SG_EL_LIST_EOL;