From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8570EC4338F for ; Mon, 23 Aug 2021 12:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AD79610A5 for ; Mon, 23 Aug 2021 12:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236902AbhHWMqt (ORCPT ); Mon, 23 Aug 2021 08:46:49 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:41936 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235954AbhHWMqs (ORCPT ); Mon, 23 Aug 2021 08:46:48 -0400 Received: from mse-fl1.zte.com.cn (unknown [10.30.14.238]) by Forcepoint Email with ESMTPS id 3711BA5E9158F9905E74; Mon, 23 Aug 2021 20:46:02 +0800 (CST) Received: from kjyxh01app01.zte.com.cn ([10.30.12.226]) by mse-fl1.zte.com.cn with SMTP id 17NCjpEJ071935; Mon, 23 Aug 2021 20:45:51 +0800 (GMT-8) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (kjyxh01app01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 23 Aug 2021 20:45:47 +0800 (CST) Date: Mon, 23 Aug 2021 20:45:47 +0800 (CST) X-Zmail-TransId: 2af96123987b663e1db6 X-Mailer: Zmail v1.0 Message-ID: <202108232045471583580@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , Subject: =?UTF-8?B?W1BBVENIXSBkaW86IGFkZCBtaXNzaW5nIGlvdW5tYXAoKSBhZnRlciBpb3JlbWFwKCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 17NCjpEJ071935 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: xu xin If kzalloc() fails, the 'va' needs to be unmapped before returning -ENOMEM. Reported-by: Zeal Robot Signed-off-by: xu xin --- drivers/dio/dio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c index 4c06c93..7d19250 100644 --- a/drivers/dio/dio.c +++ b/drivers/dio/dio.c @@ -218,9 +218,11 @@ static int __init dio_init(void) /* Found a board, allocate it an entry in the list */ dev = kzalloc(sizeof(struct dio_dev), GFP_KERNEL); - if (!dev) + if (!dev) { + if (scode >= DIOII_SCBASE) + iounmap(va); return -ENOMEM; + } dev->bus = &dio_bus; dev->dev.parent = &dio_bus.dev; dev->dev.bus = &dio_bus_type; -- 2.15.2