Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4651653rdh; Wed, 29 Nov 2023 07:12:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeg1qGkU46kZK5poUmiFiyuc5DwB+Hjgy/JUMMJge5rIgDo8X4X+W2+OjvfuikZS2jYopd X-Received: by 2002:a17:90a:e7cf:b0:280:cc2b:d5be with SMTP id kb15-20020a17090ae7cf00b00280cc2bd5bemr17703486pjb.15.1701270740830; Wed, 29 Nov 2023 07:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701270740; cv=none; d=google.com; s=arc-20160816; b=i6bgJCK7kf8TMV9nVSS93mih1HaigS0ousn3yDdCRnCnioO9avXJYKBZwL9fiG0tCM LRHaqHGKSBTYjuJ5OTaUIXgj+Zs2+CJTyRSxr/vNxMDI8ryTbZQjkKUDyqUSbPBuLa6x vu5wxaRgQ77/bFbHqh2h3VF4kW0LuVNc9UshwyVuA2FnCq0U/j1ftwgmm2s/JurVTxL1 O9B39mMcfz740SzGmQDdqda6bJi8NyC3rbSPQM+AYEjR4g4OU6lK7K/VD52qtmICsmOQ r/nXTzCiBlsI4kepmtwBe43f/XTWmVdaUPgYHm+g1HDdT/kq7fUh+u1F/Y2cuW71i+kB RbgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=feMp/yQdhv1cPkfaZTswMPfvGgf29QwDsfVs7q/7umg=; fh=yD5cBsbZMXyK6ckjJ1awMjPDKFuKMmh6XEI4G0CHyaQ=; b=O+WSCL3AgkIwHyKvD+wVAKLR3KsfBikFbAUEtWy7DzNODb3y7GLfJS4lBnh1DvPP4V r2TjCzCKBn8utPHoyNQlbTXeUuHrGnOSvp+dUAWR/9shsGgVWFnMv3fF5iBqeeISnVBX QGBqEIhuofjRejgs1pMRg99vpXB4t+/ooarWd4P9nc9C5fWMg+3mN0vfz1XaTkjn6P/q 5gKiJ9o2jCy95D1gjG0ONhORAi2SJyYCrO532Y6K/igSvgtiMIOcgJcz7q88XpWGVh7r JIUkEdyEncwJaIF9b2HG3ldFtTT8qZFdcMADPi199kFD9jq7gb0f893VsHyJfd9GbImD AM+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=meQcnt+x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ie24-20020a17090b401800b0027d22d5aa7esi1466470pjb.46.2023.11.29.07.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:12:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=meQcnt+x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BFB63809FA37; Wed, 29 Nov 2023 07:12:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231240AbjK2PMA (ORCPT + 99 others); Wed, 29 Nov 2023 10:12:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjK2PL7 (ORCPT ); Wed, 29 Nov 2023 10:11:59 -0500 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3C7EBE; Wed, 29 Nov 2023 07:12:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=feMp/yQdhv1cPkfaZT swMPfvGgf29QwDsfVs7q/7umg=; b=meQcnt+xpXwd4m9WQE94rE3uXOU9rxyby3 nCUuPH1Jmj8w+ncT1y6F9uYoaN806rnOYheXjvJnj1241XXTv79QDufXln9BrUDG /3jJ+Q0te7YPGdQVn7IH1DOGXjpffx6uMc5mxKGsH1c8T1qC8pgIm29BMNWFNN1V 6zShKMRU0= Received: from localhost.localdomain (unknown [39.144.190.126]) by zwqz-smtp-mta-g4-4 (Coremail) with SMTP id _____wC3njG5VGdlx_XzEA--.39554S2; Wed, 29 Nov 2023 23:11:55 +0800 (CST) From: Haoran Liu To: jejb@linux.ibm.com Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Haoran Liu Subject: [PATCH] [scsi] sni_53c710: Add error handling in snirm710_probe Date: Wed, 29 Nov 2023 07:11:52 -0800 Message-Id: <20231129151152.34829-1-liuhaoran14@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: _____wC3njG5VGdlx_XzEA--.39554S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kry7ur4fKF18JryDCrW3Wrg_yoW8Wr45p3 9xGw45Ca97GF1xA343Xa18u3Z0yaySkrZrK3W7W3sI9a1rJFyYqr4SyFyagFW8GrWktF4U Xr1UtFWI93WDCa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRa9akUUUUU= X-Originating-IP: [39.144.190.126] X-CM-SenderInfo: xolxxtxrud0iqu6rljoofrz/1tbiZRo3gl8ZaQ-qYQAFsk X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:12:17 -0800 (PST) The patch adds checks for the return values of dma_set_mask and ioremap. Previously, the function did not handle potential failures of these calls, which could lead to improper device initialization and unpredictable behavior. Although the error addressed by this patch may not occur in the current environment, I still suggest implementing these error handling routines if the function is not highly time-sensitive. As the environment evolves or the code gets reused in different contexts, there's a possibility that these errors might occur. Addressing them now can prevent potential debugging efforts in the future, which could be quite resource-intensive. Signed-off-by: Haoran Liu --- drivers/scsi/sni_53c710.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c index 678651b9b4dd..41414d0c64f8 100644 --- a/drivers/scsi/sni_53c710.c +++ b/drivers/scsi/sni_53c710.c @@ -69,8 +69,19 @@ static int snirm710_probe(struct platform_device *dev) return -ENOMEM; hostdata->dev = &dev->dev; - dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); + rc = dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); + if (rc) { + printk(KERN_ERR "snirm710: dma_set_mask failed!\n"); + goto out_kfree; + } + hostdata->base = ioremap(base, 0x100); + if (!hostdata->base) { + printk(KERN_ERR "snirm710: ioremap failed!\n"); + rc = -ENOMEM; + goto out_kfree; + } + hostdata->differential = 0; hostdata->clock = SNIRM710_CLOCK; -- 2.17.1