Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4027810rwl; Tue, 27 Dec 2022 20:37:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXuotIoT6BkZ29XR2FK1OhpF4YKY/vjRpgLPYm/vFmq13OP/uCR5yQ0D8pniLaMO9/edwUrU X-Received: by 2002:a17:906:684b:b0:7c1:2fc2:6740 with SMTP id a11-20020a170906684b00b007c12fc26740mr20542869ejs.46.1672202262096; Tue, 27 Dec 2022 20:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672202262; cv=none; d=google.com; s=arc-20160816; b=lLpbabNE/Yj/iCGBStWdbEpxMruDeAKIhFjlqAjjUA/XqTnB4YGwWyJEQS88A7vFSe hdtOUrL77d3g/aiEkbdFKIVWkEbeFCd+h1sM9AEC9zt1ZBkQRodBH1zQNVtllcUAsKMn +kiKdR+fNIG6JcczEjsb69ZhUJmbS4yB9WWwtVT2qEbDE8UZGDwtyKWlQw69fPKSDWqk 8PhbI3kChOjY917aXIgOeBSHarMr46mHdPnqyBy9kx26Zmp3KrMwlxdwHfuCNH0LDYBK x1MojCYjFBa8xQhUbw31eEqyunoKnNhdVP+M9finqAlFdlRQJBuDE2h2KufbuR7W3VBj G09Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=K8PhvaLKi+9bJAgGM05b1cXdyx00DUCYWQAZlbqot6k=; b=wd21j5FGdVT9BlB0VMxjITgoFAbWrWy/6RMMPLu9rEq/+fq2+y19Q9YnTuENSvwFdx YQidisaWsI3w6HUVcRq7lmcsd/olF9r/z7BUJekwAMElwWnB5jJrj/PWs+8mNlUWSQej ujm5rhGHvQNv6lpWmi+PV4s81DCEkFYBbebFViN8QMoGSiquBKHbFpDgES55P0/mYECK ba7n60YaU82Ru1MKRAJT5+vznyvaFjG651qmRLr8pKvLy+1lhp8ET2P+HcT7XL+dnmn9 /ZhwQWVGim9oYtfVJaVzE59l2IrKQ30RMjGk3KuA3FyrJJhlX3DjBiV5AtW6mJZLd4X1 yZMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a170906595900b007c0a9aca484si10300382ejr.755.2022.12.27.20.37.23; Tue, 27 Dec 2022 20:37:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiL1EZO (ORCPT + 66 others); Tue, 27 Dec 2022 23:25:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiL1EY6 (ORCPT ); Tue, 27 Dec 2022 23:24:58 -0500 Received: from cstnet.cn (smtp80.cstnet.cn [159.226.251.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B174DB1; Tue, 27 Dec 2022 20:24:56 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowAB3oO4BxatjmXuOCQ--.8808S2; Wed, 28 Dec 2022 12:24:49 +0800 (CST) From: Jiasheng Jiang To: jejb@linux.ibm.com, martin.petersen@oracle.com, john.garry@huawei.com, damien.lemoal@wdc.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] scsi: libsas: Add missing check for dma_map_single Date: Wed, 28 Dec 2022 12:24:31 +0800 Message-Id: <20221228042431.24923-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowAB3oO4BxatjmXuOCQ--.8808S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Gr15ZF1DZw4xZF1UCrWfZrb_yoWfKFb_Cr WUW3Z3WryDCrs3tw1jqFy5ZryFyw4kWFnY9wn2v393A34YqFWfW34jvFy8Zw48Gw4UCFy5 Jay7CFs5Cr1DtjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbzkFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F 4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHUDUUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.25.1