Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934657AbcCIXt2 (ORCPT ); Wed, 9 Mar 2016 18:49:28 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:40619 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934516AbcCIXP5 (ORCPT ); Wed, 9 Mar 2016 18:15:57 -0500 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Dan Carpenter , Jonathan Cameron , Kamal Mostafa Subject: [PATCH 3.13.y-ckt 020/138] iio: inkern: fix a NULL dereference on error Date: Wed, 9 Mar 2016 15:12:27 -0800 Message-Id: <1457565265-15195-21-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457565265-15195-1-git-send-email-kamal@canonical.com> References: <1457565265-15195-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.13 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1185 Lines: 36 3.13.11-ckt36 -stable review patch. If anyone has any objections, please let me know. ---8<------------------------------------------------------------ From: Dan Carpenter commit d81dac3c1c5295c61b15293074ac2bd3254e1875 upstream. In twl4030_bci_probe() there are some failure paths where we call iio_channel_release() with a NULL pointer. (Apparently, that driver can opperate without a valid channel pointer). Let's fix it by adding a NULL check in iio_channel_release(). Fixes: 2202e1fc5a29 ('drivers: power: twl4030_charger: fix link problems when building as module') Signed-off-by: Dan Carpenter Signed-off-by: Jonathan Cameron Signed-off-by: Kamal Mostafa --- drivers/iio/inkern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 4fc88e6..e08b28f 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -325,6 +325,8 @@ EXPORT_SYMBOL_GPL(iio_channel_get); void iio_channel_release(struct iio_channel *channel) { + if (!channel) + return; iio_device_put(channel->indio_dev); kfree(channel); } -- 2.7.0