From patchwork Mon Oct 5 13:22:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 7327501 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 88AD49F1D5 for ; Mon, 5 Oct 2015 13:23:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B935620693 for ; Mon, 5 Oct 2015 13:23:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7F6B92068E for ; Mon, 5 Oct 2015 13:23:05 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A68CA2605E8; Mon, 5 Oct 2015 15:23:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 4BBD4260586; Mon, 5 Oct 2015 15:22:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 63F80260599; Mon, 5 Oct 2015 15:22:54 +0200 (CEST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by alsa0.perex.cz (Postfix) with ESMTP id 0C668260547 for ; Mon, 5 Oct 2015 15:22:46 +0200 (CEST) Received: by pablk4 with SMTP id lk4so176466759pab.3 for ; Mon, 05 Oct 2015 06:22:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=RpM0ULO2BPmhOLnu9z3jtvgnoqElfQc0tnn2ITeGp+w=; b=ORlBn6NJ6TuVmtRxgNOSzzJ7mOGfZocv3nkoRL1uAN4XlT88Fh9uMLbBxwHFBHv/rI iRxdkdX0EW4GtWVec1Vn3G0tvE5T86bCT/J9UXAd530vtn550pILKJVRmm31Zv8G+scR GNzHKStVdUXuCq8sUsDsEZV27ULXjnVGRoD+TusfczZ3dCrDI+ZDN2mTYBZ0LwcxcARA VpnqTEDZfhYMi349dYnmTl4eQKk5sxWVwmM3rqwlKWBtWiC6JPB+LrI1aRDzLZ3bXEtv j3PohqHB60AM6FwApLKPfz68BVD3gs2yEn6SHF0yWGGSMfMnGRwEwKmrb63EsiAUCOsb ExNQ== X-Gm-Message-State: ALoCoQlVW0ZIv45jb5trix2F89exd78uIjmBvCkSaHZsxHjgaShyVj8eX9xPnL+6id+rUS5w9oGk X-Received: by 10.69.1.5 with SMTP id bc5mr39989386pbd.151.1444051365718; Mon, 05 Oct 2015 06:22:45 -0700 (PDT) Received: from phoenix ([60.245.65.112]) by smtp.gmail.com with ESMTPSA id sl7sm27711643pbc.54.2015.10.05.06.22.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2015 06:22:44 -0700 (PDT) Message-ID: <1444051360.13473.1.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Mon, 05 Oct 2015 21:22:40 +0800 X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Cc: Oder Chiou , Bard Liao , alsa-devel@alsa-project.org, Liam Girdwood Subject: [alsa-devel] [RFT][PATCH 1/2] ASoC: rt286: Fix run time error while modifying const data X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Make a copy of memory for index_cache rather than directly use the rt286_index_def to avoid run time error. Fixes: c418a84a8c8f ("ASoC: Constify reg_default tables") Signed-off-by: Axel Lin --- sound/soc/codecs/rt286.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 1fbdb4f..af2ed77 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -37,7 +37,7 @@ #define RT288_VENDOR_ID 0x10ec0288 struct rt286_priv { - const struct reg_default *index_cache; + struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; struct snd_soc_codec *codec; @@ -1160,7 +1160,11 @@ static int rt286_i2c_probe(struct i2c_client *i2c, return -ENODEV; } - rt286->index_cache = rt286_index_def; + rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def, + sizeof(rt286_index_def), GFP_KERNEL); + if (!rt286->index_cache) + return -ENOMEM; + rt286->index_cache_size = INDEX_CACHE_SIZE; rt286->i2c = i2c; i2c_set_clientdata(i2c, rt286);