Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1250447imm; Fri, 28 Sep 2018 14:56:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV61kVNFC0ReCVr4Kcha25K+u1wWR/nFOF6XpLXa2Vygpj4I8EHl939tOGH/jYwq0mfSJkgGG X-Received: by 2002:a17:902:464:: with SMTP id 91-v6mr485950ple.125.1538171801206; Fri, 28 Sep 2018 14:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538171801; cv=none; d=google.com; s=arc-20160816; b=n/ilsAV/A257ESuePV7Cscnz7vSJR3WDStGMhDMTP9yoy+kukyZC0UIzeO4v7smeIa wjCSVfibsVhciFXLFOJDb33AszKTKoMv7H53oB5jFCipbaRxxdSg047dUspl/9yfm9TQ pPm+4OYWPU8/v36Gu/5wY3o2BRl9FBELcCr349sY4R7zU5uheZ9kEMQQSncSwJurvKJk 6wFqe/HoHCwGWuzpCsbKP6nIqvtcvLdGBW/pYFfrcIUeHubfyY3hk0ddr44k+6waSwLo 6haIzkL4cikXFccdFmNE2S9M2PZh3jP6kXfbNXnHwU73hyyWiO2KGUnskaU4zi5FqZLz +zcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=6s+ZOaICUZVRqFQ9Pv/dCWYlSkWok16ggXbo3r84W2Q=; b=yowtNwpv4+pQB7mAEK82Ry6Txk99HXbaIvLOtnnu+bpbu/kMjVovNeeQYtPCHMy6GE 8DqZvgMsUtgKKswv3ZDaqrrywlIEggXDtE9uW7DVHWpthNHwy+kbPqbwz6I1QVLW08Fn sH85R1+11ooHzJlG/0eRBVgYEaPrsINUiaJbmlZZeQW4w6Ex/G7xU0eVWin76dqLBSpb VHMi6FYATfA2W91BoNvdwSUxY6cSRdQ3pNm9dcM3mNTinuiu0boy07Fw0BCx+yvhCoYz FZkFNLT3HyJ8mQBt8whvj13hMPTBhWhCgl3TzANkghRUkfqZHPHPkmg8KOkPHUb0Dnf8 qBZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D8jdbwt6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21-v6si5517618pgs.520.2018.09.28.14.56.26; Fri, 28 Sep 2018 14:56:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D8jdbwt6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbeI2EUh (ORCPT + 99 others); Sat, 29 Sep 2018 00:20:37 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:39634 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727443AbeI2EUg (ORCPT ); Sat, 29 Sep 2018 00:20:36 -0400 Received: by mail-yb1-f196.google.com with SMTP id c4-v6so3300519ybl.6 for ; Fri, 28 Sep 2018 14:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6s+ZOaICUZVRqFQ9Pv/dCWYlSkWok16ggXbo3r84W2Q=; b=D8jdbwt6VfkvtaKVwYzuPqub/PpKJYeY85GZPTxtpFsuy7XvyVeyg87DCnqkh8O+Yp cQ7iG68cB0HY02JI7E07JfUjlC367kyLDEuCQyeKhSxS7x1hqDZgD+40PkiyeDa+5hN1 49pWO1FnQXIjxiby1ygKnqqn5KZHf16zdWG0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6s+ZOaICUZVRqFQ9Pv/dCWYlSkWok16ggXbo3r84W2Q=; b=oXOgLYFKFyktDMlRu87NT0nu/bpVIl2hNMtvOi6C8A/CUZ936PSNfHALB3/sUTfLj/ 0LrMta7mITuYIP/AWtPDgUxOYv1jJTE7ZFOr2GJNZO9MSwyhl0eI9mZO/W83gfxkV2hS 5cDLS3IN4fj1iMLHFVKHVK7uzudaM4ujAAYee2wULVSTbmmPf/HzlKHqeFJPdJ1mGTH5 RsHqpuZSRT0hsq7eNvl2nU5OEbtwrMUqIhDTAli+C8gTrMTXgo6L6IIhOKccyC/EiU/Q FsyEV6ZIdPX2+IKeN672k1IiQ524rpMDysU6iZIB3pdupdM2vG2zX5NNUKvEwBYMabrw /YqA== X-Gm-Message-State: ABuFfoiUxxprxTfj1H0RcBNTTzUzAcx7y6z5uEXOqG20N28uCEqHa+QY 6cCQFFWuKoavdGqJL+qG7GAs98pBodE= X-Received: by 2002:a25:b3c9:: with SMTP id x9-v6mr333129ybf.508.1538171693961; Fri, 28 Sep 2018 14:54:53 -0700 (PDT) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com. [209.85.219.171]) by smtp.gmail.com with ESMTPSA id w207-v6sm8973504yww.17.2018.09.28.14.54.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 14:54:52 -0700 (PDT) Received: by mail-yb1-f171.google.com with SMTP id w7-v6so3296441ybm.7 for ; Fri, 28 Sep 2018 14:54:52 -0700 (PDT) X-Received: by 2002:a25:dd82:: with SMTP id u124-v6mr320269ybg.171.1538171691994; Fri, 28 Sep 2018 14:54:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:d116:0:0:0:0:0 with HTTP; Fri, 28 Sep 2018 14:54:51 -0700 (PDT) In-Reply-To: <20180928142630.f4501105f413f2b5b4772a8b@linux-foundation.org> References: <20180917091531.21356-1-nixiaoming@huawei.com> <20180928142630.f4501105f413f2b5b4772a8b@linux-foundation.org> From: Kees Cook Date: Fri, 28 Sep 2018 14:54:51 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fix memory leak in ramoops_init To: Andrew Morton Cc: nixiaoming , Jan Kara , Amir Goldstein , "linux-fsdevel@vger.kernel.org" , LKML , Joel Fernandes , Geliang Tang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 28, 2018 at 2:26 PM, Andrew Morton wrote: > On Mon, 17 Sep 2018 17:15:31 +0800 nixiaoming wrote: > >> 1, memory leak in ramoops_register_dummy. >> dummy_data = kzalloc(sizeof(*dummy_data), GFP_KERNEL); >> but no free when platform_device_register_data return fail >> >> 2, if kzalloc(sizeof(*dummy_data), GFP_KERNEL) return NULL, >> but platform_driver_register(&ramoops_driver) return 0 >> kfree(NULL) in ramoops_exit >> so, add return val for ramoops_register_dummy, and check it in ramoops_init >> >> 3, memory leak in ramoops_init. >> miss platform_device_unregister(dummy) and kfree(dummy_data) >> when platform_driver_register(&ramoops_driver) return fail > > Looks right. > > It's unclear (to me) who maintains fs/pstore/ram.c. Let's add some > Cc's and see if we can catch a reviewed-by. It's me: PSTORE FILESYSTEM M: Kees Cook M: Anton Vorontsov M: Colin Cross M: Tony Luck S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore F: fs/pstore/ F: include/linux/pstore* F: drivers/firmware/efi/efi-pstore.c F: drivers/acpi/apei/erst.c F: Documentation/admin-guide/ramoops.rst F: Documentation/devicetree/bindings/reserved-memory/ramoops.txt K: \b(pstore|ramoops) I'll take review it and take it via the pstore tree. Thanks! -Kees -- Kees Cook Pixel Security