mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Farhad Alemi <farhad.alemi@berkeley.edu>
Cc: Mark Brown <broonie@kernel.org>,
	falemi@asu.edu, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: dln2: validate chip select count reported by the device
Date: Fri, 11 Sep 2026 10:00:08 +0300	[thread overview]
Message-ID: <aqOm-NtZiNeTOgSk@ashevche-desk.local> (raw)
In-Reply-To: <CA+0ovCivEREvoy=Z-D5TSddgTfFknhFrCBPON3a7QD2Kne=MTA@mail.gmail.com>

On Thu, Sep 10, 2026 at 09:43:38PM +0000, Farhad Alemi wrote:
> dln2_spi_get_cs_num() stores the chip select count reported by the device
> straight into host->num_chipselect, and dln2_spi_cs_enable_all() then
> evaluates GENMASK(num_chipselect - 1, 0), whose shift exponent is out of
> bounds whenever that count is zero or larger than BITS_PER_LONG. The
> resulting mask is handed back to the device in a u8 field, so any count
> outside 1..8 is invalid regardless. Reject such counts with -EPROTO in
> dln2_spi_get_cs_num(), where the value is first read.

You need to check with the datasheet. It says that only 4 SS lines can be
programmed. The reserved bits must be held in 1. So, all in all, the _MAX_CS
should be 4.

> Closes: https://lore.kernel.org/all/CA+0ovCioY634b646jDcs2cFmg_1q2UMN4wuTQ1V26Gy+Dm_c+A@mail.gmail.com/
> Signed-off-by: Farhad Alemi <farhad.alemi@berkeley.edu>
> ---

Datasheet: https://diolan.com/media/wysiwyg/downloads/dln-api-manual.pdf

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-09-11  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 21:43 Farhad Alemi
2026-09-11  7:00 ` Andy Shevchenko [this message]
2026-09-11 13:46 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqOm-NtZiNeTOgSk@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=falemi@asu.edu \
    --cc=farhad.alemi@berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®