Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7457512ybp; Wed, 16 Oct 2019 08:57:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrc/RHJpBBTO9pAKlHupOQ+ofp9u/Ur8i6etyhgniaLn92qPxeRwZ5yIDC1Lhgmk+w3wSa X-Received: by 2002:a50:98c6:: with SMTP id j64mr39876706edb.295.1571241452778; Wed, 16 Oct 2019 08:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571241452; cv=none; d=google.com; s=arc-20160816; b=OlUk6RpgNVlP6sfhZdZTIXAR4GrX9OONTABSThHzgKcEqucYoJk1v5UpMbBqvoPDZc qnGl8hWsrK7BcUFQMTu7/ECm6aZWmdqYhRIgRYwgTkOlbIk4jIn7eL2jKStHYuVpUw3n vFVgLVY67nqfnIjolCeTotqOy67chTHTVmw3XCwO7IWbW2iFaOYrz2SvzXO1NQi5SxYt hXL988tl6acVoen5U/MR1cOeJOX12WpF88g8427uZ5JoITm84GGHafj1tIKfIZoTLVUY F2OkTrCDKxt36p2WKkpW2t9s1oC76SOaD+uBh1QmDG5IvNufYfJ05xs3JEOo9nR3oKXX yLAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=8a9HNA2BKGzGwxQrVAzjlpqsmr7lfX1r2QUJLnuq4M8=; b=N8EbO++1fbh6SiAilaRqystA71lFZwcHeEo72MSjjpf0yyFHjm8QP1x3wG13aaF+dk /kj+7Ew7Pk64l8fB7L2Wzs8WCw/YmSk3kM9LDVnjdrfh+HyWCe5oxT/uGahiEGfDGTUd fO1q+JwSwhn/bH/vpHF0FIkirxOxrmMM1FnknYkH+Qr0TNa6hjIeLPtO4boKiqle+xjQ Y6X0tzvXNEgMu3fJOs6n+9c2ldlhVdyMGws2douXW6/avr1AMTpiWiB1NIWaUFkETPCh 64rF014tpv2l+wHX8WAjOArIPikDJwAmRZ5vWfbSDK6d+5Q2uAn5FVI5ds6+4YagVhuK TQxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZUUc212a; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a41si17528263edc.180.2019.10.16.08.57.09; Wed, 16 Oct 2019 08:57:32 -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=fail header.i=@gmail.com header.s=20161025 header.b=ZUUc212a; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391523AbfJPMyg (ORCPT + 99 others); Wed, 16 Oct 2019 08:54:36 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44485 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbfJPMyf (ORCPT ); Wed, 16 Oct 2019 08:54:35 -0400 Received: by mail-pg1-f195.google.com with SMTP id e10so10261090pgd.11; Wed, 16 Oct 2019 05:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8a9HNA2BKGzGwxQrVAzjlpqsmr7lfX1r2QUJLnuq4M8=; b=ZUUc212azMCOIP56SZCnXe9tI35MmHs9g8a+tqb/WMJmGQ1dJKa83hOdA91+Mav88U 8MpozPbLu0g3jY80UGoIFAy+AT9ljM5Nyl3fD5UaAtWWNHm0GRvP5QvAFPNfTvM5wOOL /UaUEo07Zx5U3olsTfM38GliySpyAt5iZum+AdKo7EC38tgQBT+NO5UCZXGzsDnytyF2 AgRp02Ei2cmQT3AAJlzdvPx6o0EUlorvm2QV1tuYqwzppzuWRAMv6U460znOzKsHn1WH 69q25o8g8+sixoJuNZPVeIYyDRLLABE2cdBIxvO7mwLFn/NarAzZl6OUNVAvqiwk69r/ yK7g== 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:mime-version :content-transfer-encoding; bh=8a9HNA2BKGzGwxQrVAzjlpqsmr7lfX1r2QUJLnuq4M8=; b=AZ2KmnnAQ3Eq+wAbI6DxKepcinF67gGfc/W5Jy/YQwGyvg3qU544/7zVxkL6LJejhF Y7hbDBr/P5pg5BJaLZOY6TxcEU46t9e/n1pBKUcPlP2GLth+ZD3SLKr4oitRPFcApV1V 7nq0rIb8Y0pVEAEBDERLlPt0hkaKB/uwhJISIvW/TA8cHCa4O6n63OPH/iMbs+WzvfdM cF9BOx1Bs6WWu0Xoy1MBbaedO5hmgC7HOw70WHOeexNb0RmuJkCU130mHDhCikHLT1lj FnAy9mQHuN5QwcRmTujsTzY0TOkC7dz4uXL7XF5IYgtD5kq1f/2dZqURZitUaUyD2Vju o+iQ== X-Gm-Message-State: APjAAAXC0F59cDR5w/XmXp29BeFLF40lYB5P6NEMbXSaTot0lXIt3ySb I91/jD8QYtJtxFBS6JGb+VI= X-Received: by 2002:aa7:8b4d:: with SMTP id i13mr45697833pfd.226.1571230468438; Wed, 16 Oct 2019 05:54:28 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id r18sm19049233pgm.31.2019.10.16.05.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 05:54:27 -0700 (PDT) From: Chuhong Yuan Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v2] leds: an30259a: add a check for devm_regmap_init_i2c Date: Wed, 16 Oct 2019 20:54:03 +0800 Message-Id: <20191016125403.23359-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org an30259a_probe misses a check for devm_regmap_init_i2c and may cause problems. Add a check and print errors like other leds drivers. Signed-off-by: Chuhong Yuan --- Changes in v2: - Use goto exit instead of return to destroy the mutex when failed. drivers/leds/leds-an30259a.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index 250dc9d6f635..82350a28a564 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -305,6 +305,13 @@ static int an30259a_probe(struct i2c_client *client) chip->regmap = devm_regmap_init_i2c(client, &an30259a_regmap_config); + if (IS_ERR(chip->regmap)) { + err = PTR_ERR(chip->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n", + err); + goto exit; + } + for (i = 0; i < chip->num_leds; i++) { struct led_init_data init_data = {}; -- 2.20.1