Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765816AbcLVKdh (ORCPT ); Thu, 22 Dec 2016 05:33:37 -0500 Received: from mail-db5eur01on0069.outbound.protection.outlook.com ([104.47.2.69]:47712 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759423AbcLVKdd (ORCPT ); Thu, 22 Dec 2016 05:33:33 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=markb@mellanox.com; Subject: Re: [PATCH] ib umem: bug: put pid back before return from error path To: Kenneth Lee , , , References: <1482390692-147946-1-git-send-email-liguozhu@hisilicon.com> CC: , , , , , , , , , From: Mark Bloch Message-ID: Date: Thu, 22 Dec 2016 10:00:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1482390692-147946-1-git-send-email-liguozhu@hisilicon.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [213.57.216.47] X-ClientProxiedBy: VI1PR07CA0089.eurprd07.prod.outlook.com (2a01:111:e400:7a52::15) To AM3PR05MB1332.eurprd05.prod.outlook.com (2a01:111:e400:586e::18) X-MS-Office365-Filtering-Correlation-Id: e794449c-6490-4903-f6bf-08d42a40aca2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM3PR05MB1332; X-Microsoft-Exchange-Diagnostics: 1;AM3PR05MB1332;3:2NvwuERMtjk8LJIt4gpmkCik1m3IzC/w3+VxLe5KweYMZ4/mvSh+keQJZgeEP/gFEZQfB5VM0XgkFYQJ1h2mG/hQLVoFtPQKVNyOaHxHdOynN5+gNuChx14ocHOveOQFuJijDPS0Xk+s1zCUqpaEgPreQmi5lXLTKLw5d9NdhfqWO4Q2ZCkDX3ZVZOPeF6CrI6UgVK9NXGaLJvnUnih8Jj/wlU0nfn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yamVUKC0TIsM/K/R4nMwUUOrsK1VvWClqKSvWWnMBmBPIx1Vi5HyH6yE0cg+b9lJrwCMr+FSZd/hOqZyUxYKB+WuVpT8W2UmyM342oCCeQJkHY8YdKqq6Smpyy+Wrwo/tb14std915OrxmF3RdrPtnGkN0iO8cZ4t6DKu28vv7z2w9vC5FY/aUSxQhUMN2UJ2eqSgj5BQTlH4SwQ0ztoqSe7PSMf59xuhKyYJ9TsBmzy6oL1/Tt+H3tXsqHDChBQqM8Rc8w8mdSiam+ewQKajIHJggXKt/wUEqH/W8cksUXztXiKm9C7/U5jHSeo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(6072148);SRVR:AM3PR05MB1332;BCL:0;PCL:0;RULEID:;SRVR:AM3PR05MB1332; X-Microsoft-Exchange-Diagnostics: 1;AM3PR05MB1332;4:s4Cr2ffhU8b+VlmHPcAp9c3mN8zaOD/4w+FzJuT1/WndS8VO5ECMpJGr2lDzf/YcezSPgayj3bYg1p9YeIAGuDUtbIuZ/9KwAIvVibtQRRrqEkJqn4BZx37HVS5/rfB8L3z2U4KwVgN/aAnQfZ7LMr3G6iVFOK6m7p1erDbT3bf1b8U4QbXfgISoIOexeOcK2APAONtZvaH4ufAoWxzPUdsCn1yhBGFsmdHUKYbVx3Z/34KbF7uNwZbmtf5SOw/jYQnEZv++RRJ3dFWAZBjctguhSH9Emh+g9M0XUwS/X/y0NPgPtV3x1YFsq196Qu+rW728dR5P5/jE0Kjr6HQIhV0oEWvCnsW02rkOqqm/3iqDzrdavnAx/TrgSPGmg+tQndZImrbWOCdrid+bNblpxXI3ZcBvIUgr1x6s9Oyu7ZYGhWGv6tNr8Oi5h5mYvf8X4dI7Svq8dmutkV1hWnpfQ9eP4D/VSdqrbRvcD5qAD/EPFolFI7rsdnb8fjFkQrUVPAEXKTlpmdyu8ko18D7ETM2hyFyHsohMHHqG4casmApVCCMjIfWA5egGM5utcN2XG3TRKJZ9AZ+5mFAp8EAD6w== X-Forefront-PRVS: 01644DCF4A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(39840400002)(39450400003)(39860400002)(39850400002)(39410400002)(24454002)(189002)(199003)(77096006)(66066001)(65956001)(65806001)(39060400001)(6486002)(50466002)(33646002)(47776003)(92566002)(38730400001)(31696002)(7736002)(2201001)(7416002)(6666003)(86362001)(83506001)(229853002)(2950100002)(65826007)(106356001)(105586002)(2906002)(81166006)(81156014)(5660300001)(76176999)(54356999)(8676002)(117156001)(5001770100001)(4326007)(305945005)(97736004)(31686004)(42186005)(4001350100001)(36756003)(23746002)(230700001)(64126003)(3846002)(6116002)(189998001)(68736007)(101416001)(50986999);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR05MB1332;H:[192.168.1.12];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;AM3PR05MB1332;23:7KTJO/QJmqm7UtMk3DRf3OkKFd0V+QXkBffx4?= =?Windows-1252?Q?IIf+YoiyhT2+Q4O2LRFcUjjemE695BrmDzzJp2YRjrJrOmcYJ1cgoNVN?= =?Windows-1252?Q?/mXhAi0SRMRd5QUn9sbH6v6NJLCDIlwQ7a291hXg62PuL/n+z7qw9yD7?= =?Windows-1252?Q?ut8fTpTgY5liuQSs0gOMbqWnBz6A+3NGJRT8EUBdueZUXWVJFuWHwhoi?= =?Windows-1252?Q?ssq6QIj9G81xGgL/lc7uqhjVInCiCPSpoVXon8oSkURrRymMFqela0Cm?= =?Windows-1252?Q?mKi5tg6bbkyIERr0qVtzHZJfCvJPkUAx3mWObH5n1OAqED1Tu2I/z0ih?= =?Windows-1252?Q?RNKTjTF+9k1KcsdeO2r97mZ2KJpSuEYWu2EVhAgGTtYAep+QnRvYLIOJ?= =?Windows-1252?Q?KziZWPdNERoI+O8dhtZPCDc/2E/B9BwrYfSqThLo3J6qtVOks6aCWGz8?= =?Windows-1252?Q?NHf5DLizdVXgp/jDUpMBMnD/po4s7+hVKbjJV74Du1Z2gVwwQBQ9EbBd?= =?Windows-1252?Q?pupnljczUmlCnEqyghO044ny7WrCllOzeP9UubpAKw6GFAP5FQaUr5m0?= =?Windows-1252?Q?Ic2g4gFKOoXhjnZLx/mgY+FzCnvcrtLX6GSENOUcR2vRFMnv81Tksjr6?= =?Windows-1252?Q?m1IhVsbkLancfWl3r9GvoDRRlkePjWmIwEYdYAORvE/uJ5RnoS5n6JF7?= =?Windows-1252?Q?UQ+0WkVkwGet+cEgsPmEkxWqmn94GsDI1yJrHgb2cZI0uXaLKaP+Paj/?= =?Windows-1252?Q?u4SvLD6T13e3QMlbJHXutg3wiTT5h02M+BHRAmSUlCcYJ3yvQqZcyuNL?= =?Windows-1252?Q?+pL7h8nKkL2KWwyPsmcEiMSrnYe9ZCl9EOgYLSbksMW2Lf+EUr5dc33h?= =?Windows-1252?Q?n0lOnh0HlehKUw3JVfn10kkJymlg/01ev8gD58niOmDixszy/cBc4Dj6?= =?Windows-1252?Q?iVhW0dGsJvAPqza7fJJUGi0KkenRA8gF2VfEHXK1GZB/Xt/0XJbg0NIJ?= =?Windows-1252?Q?G3sf8wBLZuz/8yOLNbMIWS4a2hP4yOf9ATFvBfcnciLTJSj2/C1O61He?= =?Windows-1252?Q?Hd0BjMxOppq3sjhXUqfr/ZDTIPvTpo96pGBEC1mqgS8PXJ6s3FoN6TLG?= =?Windows-1252?Q?OBM3PZuTOYn5BScq/sqjBKrMLNa/SBEaiJEx7h547Rse0JnWNkuVChFE?= =?Windows-1252?Q?4h6kuFOI/UW0A46+JDTrcsOYVXXXDHziw2y9eR1H57mw7fIjuM6CiX2u?= =?Windows-1252?Q?j2R5xavqlHtapXbyJuCw2AMjW223m5oipdC0muQchVb5WC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9E4OJBGCOlN7evqxmut9z7kq8B1BOgAWy/uww= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM3PR05MB1332;7:Z+OrmChouTiUrMQtK1lPdCnsQ5PLdOeUZybSIRSWdJMH/bvRhgp6tEpaLGlIFUa0wcvd7MXzNieR8hhury0oxOCfOvoskWafIKfFKwRCGvmFJ7FQ8LElEjqxIg063jpvkA7tJwc6/OvLyn1HjNfQkPDcDgZT8OpuiWY17qVgYGHQa1xY73h/h8iIHdVvaKDb+gsJgYukWoqUn+QE/EEWWUghhejR2ZdowC01zxWzk7gquMYxd5ESkBli3Ehv08KnSLCqUrOilSKA7Ww3m0r6CKE7Fg1Pm3txKf8smI7p/PnriFDZ/5WxmskPNFFP2h0wriH1ag5Hq4kgT0cr8zVwSbGY70+2Mrzqj6JrZ+JnHclx8ai8FRx7GiGAYO6wTFTNH5Lnh6xQ0ebrBrfIa4RZ59Af2LCiyT4cfHJYLFOPpMZt8P+wSTkmhgv+vZhJYmn1TVhe3APHPD1APzv9zawuSQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2016 08:01:01.1933 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR05MB1332 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1486 Lines: 43 Hi, You have two bugs here: 1) When using ODP, ib_umem_release() checks for umem->odp_data != NULL calls ib_umem_odp_release() and returns immediately without calling put_pid(). This one isn't in the error path so the title doesn't fit. 2) In case the allocation failed, we return in -ENOMEM without calling put_pid(). Can you please resend this with proper fixes line and a better description of what is going on. On 22/12/2016 09:11, Kenneth Lee wrote: > I catched this bug when reading the code. I'm sorry I have no hardware to test > it. But it is abviously a bug. > > Signed-off-by: Kenneth Lee > --- > drivers/infiniband/core/umem.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c > index 1e62a5f..4609b92 100644 > --- a/drivers/infiniband/core/umem.c > +++ b/drivers/infiniband/core/umem.c > @@ -134,6 +134,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, > IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND)); > > if (access & IB_ACCESS_ON_DEMAND) { > + put_pid(umem->pid); > ret = ib_umem_odp_get(context, umem); > if (ret) { > kfree(umem); > @@ -149,6 +150,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, > > page_list = (struct page **) __get_free_page(GFP_KERNEL); > if (!page_list) { > + put_pid(umem->pid); > kfree(umem); > return ERR_PTR(-ENOMEM); > } > Mark.