Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp125432pxf; Wed, 24 Mar 2021 00:32:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkZE0ziMi7JRlU+0obJzjVkG8IEf358UqJM9XzMyz5ghl9QYuFcoqfGoTCqs+0nBu/auPt X-Received: by 2002:a17:906:2551:: with SMTP id j17mr2152698ejb.441.1616571136669; Wed, 24 Mar 2021 00:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616571136; cv=none; d=google.com; s=arc-20160816; b=Y5pFTlk9ln9bfAYf6QZ5OrvSh5+4XxrdHB2ARBSWlPJiRBWTIto51ymsCdo1zrXFTN r4nl5rNiEZZbaHYo/4k+y9iuSKL77WOY642fWS4qeihVVtKBTo42zogZfgIcWdoqUXHq aH6L3Z4fcs2YAZkUxAGUlWqsQOTi+Q9AWMANojzbs92hprHpyReWLQhkQwEPEPs7NXDE Tf6dr9YalQeSKad1ByaKNVBPug+RT7PVVBnzFNEEjSoYt0YyWQWPbiK9KI5XUsGOLSpE iUYznFT8tQige/2ldv2pFddelL9M+GZSSJjo2LphcwrLWlUa9oxpP3rHAydQfLNFK/lH kvyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature; bh=VB2Rli/wp6daf+0Rl+O8aL5+Mm/3G7ESffCZbqZfaRQ=; b=clf/J9z1jAjgK+nwlIEft3GOf7B2S2mmpcq0sRLUc2/m5UxDGWz2uw5/B5nodKpESQ xOmSb8NLCWftdWGg5AWYvbvMlOEUq5XBE0ft3AQL3oyneCKSyJH2x0/dJbhVULSZg6Z5 8zlNFmLLTEJFB8ZlxjR5RzvdLE1HyJm+SL0S+EZ0LqqSKCjPZkc5DXFG3UQSPcjBwrq/ 8AvkALtIDlHyVIWmU0yy73YB4/tcJMsHS3qiaYYeQLf8D3SDzylmINYQqM0f29Kby6O7 AFll3i+RHcvqV6I/D5AXsxylA5FDVXCEcp/XBNzrsAFuJSAmulTqPXOBVBDXINIVL0Uf gzzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bxDavkCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si1179606edc.70.2021.03.24.00.31.53; Wed, 24 Mar 2021 00:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bxDavkCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233592AbhCWV3Z (ORCPT + 99 others); Tue, 23 Mar 2021 17:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233533AbhCWV3M (ORCPT ); Tue, 23 Mar 2021 17:29:12 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0D5C061574 for ; Tue, 23 Mar 2021 14:29:12 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 16so27535299ljc.11 for ; Tue, 23 Mar 2021 14:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VB2Rli/wp6daf+0Rl+O8aL5+Mm/3G7ESffCZbqZfaRQ=; b=bxDavkCcCIproe94KQdt2CLKc783cy7xaHhrY0V88/NYN2lAYcrnTgAY9DBnGA1eHk 4iW+FyT+Rl+KNFwyF7uR82uJ3oSY0K5ts4XzMy6HWqzE02GGP4FPO6dqniqVqwU3e0nR VEgqcTZz9zHZ1imNYYcjTYPEpNS1Zs8hjtwssRp6xU+ZVQeoHl4h0u9zXtPj47UCFgsa 1plWTGRur+Y0v4NbZoI+i41n9ig3khbb22ReZEwnleyKySlS3kTDGA7QCqCxLM2L6Gsz tavKBcP0GK5JLnxKWJKqu/j2sjlaPk5plubvCFUAWTpCPUU4Z2ru9VCEoWQVEODHdCXY xesg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VB2Rli/wp6daf+0Rl+O8aL5+Mm/3G7ESffCZbqZfaRQ=; b=CQwFc7ZHl0pVb0LUJn8gEOyFH2MIc/OfIy+bH7PSn47pbACkPOIxgcYWnuIPN3OsXC DS77070Hn/SaSvmvj46NtKaK9mUw0TJslKqwvLrRChuAe2TBIFgsOw2QTtsIQk6xJmuM Sg08rrPD7548Vs3NaH10n3OdFPFn5ujDbKYywe4jtW899DBqe9dl1PKP0fmTVQUvLWfI JiM4fyeLSmiwDCLtr7bEPK3IUcaoJcPrZZVqC6hvx9xgHHO1d1bABNzMzwKbyeheqviY Yx12weuE6hHJ+xMd7e0ubFijxb7tSDgieUwcaC9xcRBCJ2LMNP951CPNVeeIeI4dGbyk da+Q== X-Gm-Message-State: AOAM532cniuuImH1QNG5KKgeCuxkkg2qamZwczVT+6vdBc9vCcu3zlgD 3rtDWEFHOKuZmy3OH8ItnNcY9JZefGM= X-Received: by 2002:a2e:8709:: with SMTP id m9mr4195319lji.483.1616534950847; Tue, 23 Mar 2021 14:29:10 -0700 (PDT) Received: from [192.168.2.145] (109-252-193-60.dynamic.spd-mgts.ru. [109.252.193.60]) by smtp.googlemail.com with ESMTPSA id m22sm26095lfa.170.2021.03.23.14.29.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Mar 2021 14:29:10 -0700 (PDT) Subject: Re: [PATCH v5] mm: cma: support sysfs From: Dmitry Osipenko To: Minchan Kim , Andrew Morton Cc: linux-mm , LKML , gregkh@linuxfoundation.org, surenb@google.com, joaodias@google.com, jhubbard@nvidia.com, willy@infradead.org References: <20210323195050.2577017-1-minchan@kernel.org> Message-ID: Date: Wed, 24 Mar 2021 00:29:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 24.03.2021 00:19, Dmitry Osipenko пишет: >> + if (!kobj) >> + goto out; >> + >> + kobj->cma = cma; >> + cma->kobj = kobj; >> + if (kobject_init_and_add(&cma->kobj->kobj, &cma_ktype, >> + cma_kobj_root, "%s", cma->name)) { >> + kobject_put(&cma->kobj->kobj); >> + goto out; >> + } >> + } >> + >> + return 0; >> +out: >> + kobject_put(cma_kobj_root); >> + >> + return -ENOMEM; > kobject_init_and_add returns a error code, it could be different from > ENOMEM. Won't hurt to propagate the proper error code. > I think it will be cleaner to write it like this: cma_kobj = kzalloc(sizeof(*cma_kobj), GFP_KERNEL); if (!cma_kobj) { kobject_put(cma_kobj_root); return -ENOMEM; } cma_kobj->cma = cma; err = kobject_init_and_add(&cma_kobj->kobj, &cma_ktype, cma_kobj_root, "%s", cma->name); if (err) { kobject_put(&cma_kobj->kobj); kobject_put(cma_kobj_root); return err; } } return 0; }