Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3183382ybl; Mon, 19 Aug 2019 13:43:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTttnHYXpMbiLWQDPjJz6Jv/ODrUTH8CZxzIMpd8toTo4+H0BrOBxb5PPJuVnb07Gmxw2m X-Received: by 2002:a17:902:8345:: with SMTP id z5mr25554795pln.29.1566247406171; Mon, 19 Aug 2019 13:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566247406; cv=none; d=google.com; s=arc-20160816; b=yCFjf+emuOXrPdx7jka1Gd4xFgoPZwYXQLXRNGXBtv5VDvJVTCs5iKkAkuDgSFRJAe Vb3sDkJhcDAb7H0U8Ei9AKzkKiKTBM+R6pVDbW+DDm9w2ox8yHGPUlizGzor3W5ywos/ KaXeYZoy7uqcpDuQqqmMRFWFHegSWNYtleK4xNyykzIP90FrXrgJ0+fiqgrpSPpkdGvn L7QWrDdHQ6rf0dxW3KROBneGj4cF6aMXvjpVpfRAOCyW8Q/mj4/mmAKPu+BwjwLrFt/s jdNibS8vcbWmKYn7sLcENV44VfMT/VM3aVP2ESj0G53zZD6HUeIxoXojL3Mkru+3ibN4 AlPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=4BU95eBhs+HC0NJGFEbV9d3PrjnFpSecih7BAA/6rmo=; b=IDnszlf2TRhX7KbFmjwbnPxtXXuKPNoTWfVfyMHQ+LRpET8kbDn7+3LLeYIWml7Tiz gf0qYonE5qZ5JLqUQ4Fht2ltPE5WmbdFr9x+ftPC30ak9jyhtFibO8Ob5izMCjO+iJ8V UMiJJbUjl2v23iapcWsH0kq7Yw3MEmxNNV9RMVwjKUHOXWq79YjnT1/G+TA11t7e+2vH 4MbrC7THhVSUblrzCBh3f/fAMLLpbbIUFAhy6kWf84kXf2P6syF7EY8c7l3VzSWRGX/T PCSp5aPi9glRFYSWMvqgAP8o+R1xIazj4coqdDoj14ZCSlGDxlyss4imBQ45zOxh5iJ6 IIEw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l66si10614777plb.337.2019.08.19.13.43.10; Mon, 19 Aug 2019 13:43:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728409AbfHSUly (ORCPT + 99 others); Mon, 19 Aug 2019 16:41:54 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:34061 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727980AbfHSUlx (ORCPT ); Mon, 19 Aug 2019 16:41:53 -0400 Received: by mail-yb1-f195.google.com with SMTP id u68so989427ybg.1; Mon, 19 Aug 2019 13:41:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4BU95eBhs+HC0NJGFEbV9d3PrjnFpSecih7BAA/6rmo=; b=NAAQ9aw8lVE2/KTGJcQnCSvdY1ACz6cza6cz7eeO4L4hgqm/rr0oIJly7wQuCOe3al LXYkHEiLHJ60tbfTOQ4DcEPkckNtD+crDyLJu8crky/OigSKN/Oku7ynqdFnKkaihyOU 5/jGjK2LwjFYNz1JD1huttG8qWFDL2qHNzyzoEX8k5z5eOs3+5U2d4aqzJunqu2uvIz0 sUv6WLqIY+c9rObidu4oopiOn4bK0paK19VHDYK4nZL241g++ZiZbY1FqXdFloU3N8WX 9HNxfwxQtp16IAEZJacjeeFGueUv6cRVcYh2+7UjaQE6sZV1N/13SL2uzz0EcJ5ZmH9k 6K/Q== X-Gm-Message-State: APjAAAUrhYZLHKwZ3Bdzc/hpu+1F692WM/inRPyFIYQ7UHYShvsMG7cr 0DFue2GUQloTXaNSSlacs9A+QDozu48mQg== X-Received: by 2002:a25:4d1:: with SMTP id 200mr17116222ybe.400.1566247312853; Mon, 19 Aug 2019 13:41:52 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id i201sm3282165ywg.49.2019.08.19.13.41.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 13:41:52 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , linux-leds@vger.kernel.org (open list:LED SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] led: triggers: Fix a memory leak bug Date: Mon, 19 Aug 2019 15:41:42 -0500 Message-Id: <1566247302-6217-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In led_trigger_set(), 'event' is allocated in kasprintf(). However, it is not deallocated in the following execution if the label 'err_activate' or 'err_add_groups' is entered, leading to memory leaks. To fix this issue, free 'event' before returning the error. Signed-off-by: Wenwen Wang --- drivers/leds/led-triggers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 8d11a5e..eff1bda 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -173,6 +173,7 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) list_del(&led_cdev->trig_list); write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags); led_set_brightness(led_cdev, LED_OFF); + kfree(event); return ret; } -- 2.7.4