From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BB9D33F394 for ; Mon, 26 Jan 2026 15:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442660; cv=none; b=nUooWdn4LxKiOvC97JPOf40jmmUk54O2b87Rzkz2d5e3XNemY3r4m3sDUHHJk3E+JaawSNai6EXj4lVDhwZ4wc8PKp3FneWotBUx8+8mfnrG9/umtu3hs1pSUQAhLfVfrk1F9Pwe81MNV84NuzKuAbN0fnIs0m955t0u5V9qM9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769442660; c=relaxed/simple; bh=uzTz49XE1Hx2csddmUgMnlS4lyasEN/R0ed2DF1alq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qKilOU3nLhmORgpBy6EXSsg66OJBMZHq1NkjqrFfzbpQ5yBnySowe1+WxW6pVTqfaz8WenisonvNRSibcD8i3nqFCpTHdvWXxadEy/ffCMH7khVbfPdS+8yOuQhWbYjQhNASrjYJTtzkT6bTyMx3oqguN7mL9ErMyFF/5mSrZ6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKA5f6Us; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dKA5f6Us" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BF8FC16AAE; Mon, 26 Jan 2026 15:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769442660; bh=uzTz49XE1Hx2csddmUgMnlS4lyasEN/R0ed2DF1alq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKA5f6UsvW4OkxYKus7XBjBlBs3cXcUY0kD1D+t5mNz8c5zBORHAUChNitx2yBSFr MJQ4ycxszZ27GugKq1ptKjTr6YF7euIBA+XqjtcW1xAqL2vRVr8ff1hhVm0okOVmGc 2y8ETOwAtlogTu+GmLCfzBNeNQCB/dojhB/O8kKlTkc9HEsDn7QuojmVKtazHNEqbT bdffN1C/5WQ4wSyrUVac0Tp52CyPJxMK2rjvowdVFs0rsKJU7A6kKrx2o4XoiBcN4h BAdxwncwT0OnEBm5P/j6GodhzaMNVGuNGD3KKQl6oBp3Up5tC/r5sN8igNgCndl3eX +5AUQiZHPoh9Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Yang Guang , Zeal Robot , David Yang , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15.y 1/2] w1: w1_therm: use swap() to make code cleaner Date: Mon, 26 Jan 2026 10:50:56 -0500 Message-ID: <20260126155057.3322542-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026012603-wasting-popcorn-9abe@gregkh> References: <2026012603-wasting-popcorn-9abe@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yang Guang [ Upstream commit e233897b1f7a859092bd20b10bfd412013381a10 ] Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid opencoding it. Reported-by: Zeal Robot Signed-off-by: David Yang Signed-off-by: Yang Guang Link: https://lore.kernel.org/r/cb14f9e6e86cf8494ed2ddce6eec8ebd988908d9.1640077704.git.yang.guang5@zte.com.cn Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 761fcf46a1bd ("w1: therm: Fix off-by-one buffer overflow in alarms_store") Signed-off-by: Sasha Levin --- drivers/w1/slaves/w1_therm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 67d1cfbbb5f7f..b745070e8c4ae 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -1782,7 +1782,7 @@ static ssize_t alarms_store(struct device *device, u8 new_config_register[3]; /* array of data to be written */ int temp, ret; char *token = NULL; - s8 tl, th, tt; /* 1 byte per value + temp ring order */ + s8 tl, th; /* 1 byte per value + temp ring order */ char *p_args, *orig; p_args = orig = kmalloc(size, GFP_KERNEL); @@ -1833,9 +1833,8 @@ static ssize_t alarms_store(struct device *device, th = int_to_short(temp); /* Reorder if required th and tl */ - if (tl > th) { - tt = tl; tl = th; th = tt; - } + if (tl > th) + swap(tl, th); /* * Read the scratchpad to change only the required bits -- 2.51.0