From patchwork Thu Jan 18 10:45:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10172855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F38F60230 for ; Thu, 18 Jan 2018 10:45:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C9A020243 for ; Thu, 18 Jan 2018 10:45:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00CF62465D; Thu, 18 Jan 2018 10:45:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C10C20243 for ; Thu, 18 Jan 2018 10:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755874AbeARKpi (ORCPT ); Thu, 18 Jan 2018 05:45:38 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:33542 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754927AbeARKpd (ORCPT ); Thu, 18 Jan 2018 05:45:33 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0IAic7U060545; Thu, 18 Jan 2018 10:45:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=whkswdKZUUrTDjwNXT9QCJugOr7HthKEXrMy5469720=; b=omoFO49yq2XRrblDjFeKER2uOHLLnLIb7WpzLUUvls/y4QQz43AyeSig4EHo/5USwyxq ZVrgNHH2Kmk1m+Qh++zqx63aD5RuRT66iSE/U+H/v0V32mtGrYbprvzmHUm4fsDp3cxa ev05bqMtoL9PW7h+MvMuWl6N4FsIdCM4KOZ0ZnojTt4SCGs9YRPPJVBqibcn50/7lSGT oD2J+cokr9tQd3uo1q+DAWzczo6zE7wGn+Vy7ljmUsSPw/58p1s8H2YDgCTRItTsARm5 FcApgJ4F/OI+xYP0wlcBKVYzRI1gYAkLfMyhi//T1GyQxchF7UzUGs+6NPMBkcm327Bz MQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2fjswxg19k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Jan 2018 10:45:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0IAjC96017183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 18 Jan 2018 10:45:12 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0IAjCAW007863; Thu, 18 Jan 2018 10:45:12 GMT Received: from mwanda (/41.202.241.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 18 Jan 2018 02:45:11 -0800 Date: Thu, 18 Jan 2018 13:45:03 +0300 From: Dan Carpenter To: Pali =?iso-8859-1?Q?Roh=E1r?= , Mario Limonciello Cc: Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] platform/x86: dell-smbios: Fix error handling in build_tokens_sysfs() Message-ID: <20180118104503.GA30055@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.2 (2017-12-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8777 signatures=668653 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=943 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801180153 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We're freeing "value_name" which is NULL, so that's a no-op, instead of "location_name" and then we don't free the first zero-th elements of token_location_attrs[] and token_value_attrs[]. Fixes: 33b9ca1e53b4 ("platform/x86: dell-smbios: Add a sysfs interface for SMBIOS tokens") Signed-off-by: Dan Carpenter Acked-by: Mario Limonciello diff --git a/drivers/platform/x86/dell-smbios.c b/drivers/platform/x86/dell-smbios.c index 6a60db515bda..d8a21c7ba594 100644 --- a/drivers/platform/x86/dell-smbios.c +++ b/drivers/platform/x86/dell-smbios.c @@ -512,7 +512,7 @@ static int build_tokens_sysfs(struct platform_device *dev) continue; loop_fail_create_value: - kfree(value_name); + kfree(location_name); goto out_unwind_strings; } smbios_attribute_group.attrs = token_attrs; @@ -523,7 +523,7 @@ static int build_tokens_sysfs(struct platform_device *dev) return 0; out_unwind_strings: - for (i = i-1; i > 0; i--) { + for (i = i-1; i >= 0; i--) { kfree(token_location_attrs[i].attr.name); kfree(token_value_attrs[i].attr.name); }