From patchwork Fri Mar 24 11:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 13186675 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 6FBDBC6FD20 for ; Fri, 24 Mar 2023 11:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbjCXL3F (ORCPT ); Fri, 24 Mar 2023 07:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjCXL3E (ORCPT ); Fri, 24 Mar 2023 07:29:04 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B179511144 for ; Fri, 24 Mar 2023 04:28:59 -0700 (PDT) Received: from fsav117.sakura.ne.jp (fsav117.sakura.ne.jp [27.133.134.244]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 32OBSrGD088911; Fri, 24 Mar 2023 20:28:53 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav117.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav117.sakura.ne.jp); Fri, 24 Mar 2023 20:28:53 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav117.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 32OBSrJr088908 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Mar 2023 20:28:53 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <0ae07b18-e384-5d5d-54e8-8fe508af4f6a@I-love.SAKURA.ne.jp> Date: Fri, 24 Mar 2023 20:28:50 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Content-Language: en-US To: Bernard Metzler , Jason Gunthorpe , Leon Romanovsky Cc: OFED mailing list From: Tetsuo Handa Subject: [PATCH] RDMA/siw: fix a refcount leak in siw_newlink() Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org siw_newlink() is leaking a refcount on "base_dev" when kzalloc() from _ib_alloc_device() from ib_alloc_device() from siw_device_create() returned NULL. Signed-off-by: Tetsuo Handa Fixes: bdcf26bf9b3a ("rdma/siw: network and RDMA core interface") --- I don't know whether this is a bug syzbot is currently reporting at https://syzkaller.appspot.com/bug?extid=5e70d01ee8985ae62a3b . Please check if this patch helps. drivers/infiniband/sw/siw/siw_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c index dacc174604bf..aefeda633655 100644 --- a/drivers/infiniband/sw/siw/siw_main.c +++ b/drivers/infiniband/sw/siw/siw_main.c @@ -522,6 +522,8 @@ static int siw_newlink(const char *basedev_name, struct net_device *netdev) rv = siw_device_register(sdev, basedev_name); if (rv) ib_dealloc_device(&sdev->base_dev); + } else { + ib_device_put(base_dev); } return rv; }