From patchwork Wed Jul 20 14:39:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "'arozansk@redhat.com'" X-Patchwork-Id: 12924088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66798C433EF for ; Wed, 20 Jul 2022 14:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbiGTOkL (ORCPT ); Wed, 20 Jul 2022 10:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiGTOkK (ORCPT ); Wed, 20 Jul 2022 10:40:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1472DEBA for ; Wed, 20 Jul 2022 07:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658328008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4R6On8bij0HV7pbO2X7JiLRzPOTfeLFbAfRAz4bkGvE=; b=DanYZJJ0o30kvHRJq8SQ2OpJzljpt8bs036M287TZaeqlFO6yP+Y9IPCb2MJBzQ70a1JH0 8Yb4GkGy0l8LIGnj7LDk422N57XSmiSL3JZ8dIgZQUcRpGDjQ/waoZyqoiL00a81r7dpuw 6J7/7tKfO4kSS4FsGdwR1NqJ7UjPExI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-376-96xl2yrcN5-ZYoD-yM9VtQ-1; Wed, 20 Jul 2022 10:39:58 -0400 X-MC-Unique: 96xl2yrcN5-ZYoD-yM9VtQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D30C18A658E; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: from napanee.usersys.redhat.com (unknown [10.2.16.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20AF290A11; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: by napanee.usersys.redhat.com (Postfix, from userid 1000) id DF01DC0523; Wed, 20 Jul 2022 10:39:57 -0400 (EDT) Message-ID: <20220720143957.868734458@redhat.com> User-Agent: quilt/0.66 Date: Wed, 20 Jul 2022 10:39:58 -0400 From: arozansk@redhat.com To: Mauro Carvalho Chehab Cc: linux-edac@vger.kernel.org, Aristeu Rozanski Subject: [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak References: <20220720143957.795358633@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Found with covscan. Signed-off-by: Aristeu Rozanski diff --git a/ras-report.c b/ras-report.c index ea3a9b6..0088745 100644 --- a/ras-report.c +++ b/ras-report.c @@ -768,7 +768,7 @@ int ras_report_mf_event(struct ras_events *ras, struct ras_mf_event *ev) done = 1; mf_fail: - if (sockfd > 0) + if (sockfd >= 0) close(sockfd); if (done) From patchwork Wed Jul 20 14:39:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "'arozansk@redhat.com'" X-Patchwork-Id: 12924086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F2BCC433EF for ; Wed, 20 Jul 2022 14:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229526AbiGTOkE (ORCPT ); Wed, 20 Jul 2022 10:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbiGTOkD (ORCPT ); Wed, 20 Jul 2022 10:40:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 47A7D2B186 for ; Wed, 20 Jul 2022 07:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658328002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=bL142uVpJExVyLMHAw4Afa1YfkEk/t35n231UjbltVQ=; b=hUUoWAcjGQPzaEF2vYr50wKkBMyacGO5j2kSw3xGgMQi3XTftwDcX3/9y42DmFsk/nErgH D/XcY37cy1hSutx+5BgWNiuCdQ5Y0GZCk0D+olZlpuP+jnvEknKxRCkBvce8SHJ8qpKo4e aJ6g6c5OxY8P5pnfRFC9iQ1P9rlzRVk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-g3zPPdFBNPybj_yDZ5P6ow-1; Wed, 20 Jul 2022 10:39:58 -0400 X-MC-Unique: g3zPPdFBNPybj_yDZ5P6ow-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38109858EED; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: from napanee.usersys.redhat.com (unknown [10.2.16.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BCCE400DFD7; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: by napanee.usersys.redhat.com (Postfix, from userid 1000) id EC609C0554; Wed, 20 Jul 2022 10:39:57 -0400 (EDT) Message-ID: <20220720143957.923005739@redhat.com> User-Agent: quilt/0.66 Date: Wed, 20 Jul 2022 10:39:59 -0400 From: arozansk@redhat.com To: Mauro Carvalho Chehab Cc: linux-edac@vger.kernel.org, Aristeu Rozanski Subject: [PATCH 2/3] rasdaemon: mce-amd-smca: properly limit bank types References: <20220720143957.795358633@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Found with covscan. Signed-off-by: Aristeu Rozanski diff --git a/mce-amd-smca.c b/mce-amd-smca.c index f3379fc..27ca8aa 100644 --- a/mce-amd-smca.c +++ b/mce-amd-smca.c @@ -584,7 +584,7 @@ static void decode_smca_error(struct mce_event *e) return; } - if (bank_type >= MAX_NR_BANKS) { + if (bank_type >= N_SMCA_BANK_TYPES) { strcpy(e->mcastatus_msg, "Don't know how to decode this bank"); return; } From patchwork Wed Jul 20 14:40:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "'arozansk@redhat.com'" X-Patchwork-Id: 12924087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F79C433EF for ; Wed, 20 Jul 2022 14:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbiGTOkJ (ORCPT ); Wed, 20 Jul 2022 10:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiGTOkH (ORCPT ); Wed, 20 Jul 2022 10:40:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED1B7CCB for ; Wed, 20 Jul 2022 07:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658328005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=JzZJ8/arweKn5Zbrtgd3CRnAoLDXWDayUI8QDnBw1SI=; b=huQrsKqsAjfR1dMs+yVxtocXBkAhQwBZGq/vJf2H4TN30dBGOmLf1GY93QOhwub8XsT8tk EzUGXeLUrfitTt8a/l5rNvYuAQAqKo4+iUDXmvgraNeTQ4f9/vWksXpKRC+ja4STyRFY+i gNhzosynq1HJ/6nJB8x6FsVmXGbCFzg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-O2F7j_ggM8uWNyKhxUn56g-1; Wed, 20 Jul 2022 10:39:58 -0400 X-MC-Unique: O2F7j_ggM8uWNyKhxUn56g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4948D803520; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: from napanee.usersys.redhat.com (unknown [10.2.16.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CFFB2166B26; Wed, 20 Jul 2022 14:39:58 +0000 (UTC) Received: by napanee.usersys.redhat.com (Postfix, from userid 1000) id 05BFBC0568; Wed, 20 Jul 2022 10:39:58 -0400 (EDT) Message-ID: <20220720143957.977427150@redhat.com> User-Agent: quilt/0.66 Date: Wed, 20 Jul 2022 10:40:00 -0400 From: arozansk@redhat.com To: Mauro Carvalho Chehab Cc: linux-edac@vger.kernel.org, Aristeu Rozanski Subject: [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly References: <20220720143957.795358633@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org We could just have an empty string but keeping the format could prevent issues if someone is actually parsing this. Found with covscan. Signed-off-by: Aristeu Rozanski diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c index 9941e68..9574141 100644 --- a/ras-memory-failure-handler.c +++ b/ras-memory-failure-handler.c @@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s, if (tm) strftime(ev.timestamp, sizeof(ev.timestamp), "%Y-%m-%d %H:%M:%S %z", tm); + else + strncpy(ev.timestamp, "0000-00-00 00:00:00 GMT", sizeof(ev.timestamp)); trace_seq_printf(s, "%s ", ev.timestamp); if (pevent_get_field_val(s, event, "pfn", record, &val, 1) < 0)